text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEngine;
using Object = System.Object;

namespace TarsierSpaceTech
{
    /// <summary>
    /// The Wrapper class to access ResearchBodies
    /// </summary>
    public class RBWrapper
    {
        protected static Type RBSCAPIType;
        protected static Type RBDBAPIType;
        protected static Type RBFLAPIType;
        protected static Object actualRBSC;
        protected static Object actualRBDB;
        protected static Object actualRBFL;

        /// <summary>
        /// This is the ResearchBodies API object
        ///
        /// SET AFTER INIT
        /// </summary>
        public static RBSCAPI RBSCactualAPI;
        public static RBDBAPI RBDBactualAPI;

        /// <summary>
        /// Whether we found the ResearchBodies API assembly in the loadedassemblies.
        ///
        /// SET AFTER INIT
        /// </summary>
        public static Boolean AssemblySCExists { get { return (RBSCAPIType != null); } }
        public static Boolean AssemblyDBExists { get { return (RBDBAPIType != null); } }
        public static Boolean AssemblyFLExists { get { return (RBFLAPIType != null); } }

        /// <summary>
        /// Whether we managed to hook the running Instance from the assembly.
        ///
        /// SET AFTER INIT
        /// </summary>
        public static Boolean InstanceSCExists { get { return (actualRBSC != null); } }
        public static Boolean InstanceDBExists { get { return (actualRBDB != null); } }
        public static Boolean InstanceFLExists { get { return (actualRBFL != null); } }

        /// <summary>
        /// Whether we managed to wrap all the methods/functions from the instance.
        ///
        /// SET AFTER INIT
        /// </summary>
        private static Boolean _RBSCWrapped;
        private static Boolean _RBDBWrapped;
        private static Boolean _RBFLWrapped;

        /// <summary>
        /// Whether the object has been wrapped
        /// </summary>
        public static Boolean APISCReady { get { return _RBSCWrapped; } }
        public static Boolean APIDBReady { get { return _RBDBWrapped; } }
        public static Boolean APIFLReady { get { return _RBFLWrapped; } }

        /// <summary>
        /// This method will set up the ResearchBodies object and wrap all the methods/functions
        /// </summary>
        /// <returns>Bool success of method</returns>
        public static Boolean InitRBSCWrapper()
        {
            //reset the internal objects
            _RBSCWrapped = false;
            actualRBSC = null;
            LogFormatted_DebugOnly("Attempting to Grab ResearchBodies Types...");

            //find the base type
            RBSCAPIType = AssemblyLoader.loadedAssemblies
                .Select(a => a.assembly.GetExportedTypes())
                .SelectMany(t => t)
                .FirstOrDefault(t => t.FullName == "ResearchBodies.ResearchBodies");

            if (RBSCAPIType == null)
            {
                return false;
            }

            LogFormatted_DebugOnly("ResearchBodies Version:{0}", RBSCAPIType.Assembly.GetName().Version.ToString());

            //now grab the running instance
            LogFormatted_DebugOnly("Got Assembly Types, grabbing Instances");
            try
            {
                actualRBSC = RBSCAPIType.GetField("ResearchCost", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static).GetValue(null);
            }
            catch (Exception)
            {
                LogFormatted("No ResearchBodies Instance found");
                //throw;
            }

            if (actualRBSC == null)
            {
                LogFormatted("Failed grabbing ResearchBodies Instance");
                return false;
            }

            //If we get this far we can set up the local object and its methods/functions
            LogFormatted_DebugOnly("Got Instance, Creating Wrapper Objects");
            RBSCactualAPI = new RBSCAPI(actualRBSC);

            _RBSCWrapped = true;
            return true;
        }

        /// <summary>
        /// This method will set up the ModuleTrackBodies object and wrap all the methods/functions
        /// </summary>
        /// <returns>Bool success of method</returns>
        public static Boolean InitRBFLWrapper()
        {
            //reset the internal objects
            _RBFLWrapped = false;
            actualRBFL = null;
            LogFormatted("Attempting to Grab ResearchBodies Types...");

            //find the base type
            RBFLAPIType = AssemblyLoader.loadedAssemblies
                .Select(a => a.assembly.GetExportedTypes())
                .SelectMany(t => t)
                .FirstOrDefault(t => t.FullName == "ResearchBodies.ModuleTrackBodies");

            if (RBFLAPIType == null)
            {
                return false;
            }

            LogFormatted("ResearchBodies Version:{0}", RBFLAPIType.Assembly.GetName().Version.ToString());

            _RBFLWrapped = true;
            return true;
        }

        /// <summary>
        /// This method will set up the DAtabase object and wrap all the methods/functions
        /// </summary>
        /// <returns>Bool success of method</returns>
        public static Boolean InitRBDBWrapper()
        {
            //reset the internal objects
            _RBDBWrapped = false;
            actualRBDB = null;
            LogFormatted_DebugOnly("Attempting to Grab ResearchBodies Database Types...");

            //find the base type
            RBDBAPIType = AssemblyLoader.loadedAssemblies
                .Select(a => a.assembly.GetExportedTypes())
                .SelectMany(t => t)
                .FirstOrDefault(t => t.FullName == "ResearchBodies.Database");

            if (RBDBAPIType == null)
            {
                return false;
            }

            LogFormatted_DebugOnly("ResearchBodies Version:{0}", RBDBAPIType.Assembly.GetName().Version.ToString());

            //now grab the running instance
            LogFormatted_DebugOnly("Got Assembly Types, grabbing Instances");
            try
            {
                actualRBDB = RBDBAPIType.GetMember("GetIgnoredBodies", BindingFlags.Public | BindingFlags.Static);
            }
            catch (Exception)
            {
                LogFormatted("No ResearchBodies Database Instance found");
                //throw;
            }

            if (actualRBDB == null)
            {
                LogFormatted("Failed grabbing ResearchBodies Database Instance");
                return false;
            }

            //If we get this far we can set up the local object and its methods/functions
            LogFormatted_DebugOnly("Got Instance, Creating Wrapper Objects");
            RBDBactualAPI = new RBDBAPI(actualRBDB);

            _RBDBWrapped = true;
            return true;
        }

        /// <summary>
        /// The Type that is an analogue of the real ResearchBodies. This lets you access all the API-able properties and Methods of ResearchBodies
        /// </summary>
        public class RBSCAPI
        {
            internal RBSCAPI(Object a)
            {
                //store the actual object
                APIactualRBSC = a;

                //these sections get and store the reflection info and actual objects where required. Later in the properties we then read the values from the actual objects
                //for events we also add a handler

                //WORK OUT THE STUFF WE NEED TO HOOK FOR PEOPLE HERE

                LogFormatted_DebugOnly("Getting enabled field");
                SCenabledField = RBSCAPIType.GetField("enable", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
                LogFormatted_DebugOnly("Success: " + (SCenabledField != null));

                LogFormatted_DebugOnly("Getting TrackedBodies field");
                SCTrackedBodiesField = RBSCAPIType.GetField("TrackedBodies", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
                LogFormatted_DebugOnly("Success: " + (SCTrackedBodiesField != null));

                LogFormatted_DebugOnly("Getting TrackedBodies field");
                SCResearchStateField = RBSCAPIType.GetField("ResearchState", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
                LogFormatted_DebugOnly("Success: " + (SCResearchStateField != null));

                //Methods
                LogFormatted_DebugOnly("Getting Research Method");
                ResearchMethod = RBSCAPIType.GetMethod("Research", BindingFlags.Public | BindingFlags.Static);
                LogFormatted_DebugOnly("Success: " + (ResearchMethod != null));

                LogFormatted_DebugOnly("Getting LaunchResearchPlan Method");
                LaunchResearchPlanMethod = RBSCAPIType.GetMethod("LaunchResearchPlan", BindingFlags.Public | BindingFlags.Static);
                LogFormatted_DebugOnly("Success: " + (LaunchResearchPlanMethod != null));

                LogFormatted_DebugOnly("Getting StopResearchPlan Method");
                StopResearchPlanMethod = RBSCAPIType.GetMethod("StopResearchPlan", BindingFlags.Public | BindingFlags.Static);
                LogFormatted_DebugOnly("Success: " + (StopResearchPlanMethod != null));

                LogFormatted_DebugOnly("Getting LoadBodyLook Method");
                LoadBodyLookMethod = RBSCAPIType.GetMethod("LoadBodyLook", BindingFlags.Public | BindingFlags.Static);
                LogFormatted_DebugOnly("Success: " + (LoadBodyLookMethod != null));

            }

            private Object APIactualRBSC;

            private FieldInfo SCenabledField;

            /// <summary>
            /// get the value of the enabled field
            /// </summary>
            /// <returns>Bool enabled field</returns>
            public Boolean enabled
            {
                get
                {
                    if (SCenabledField == null)
                        return false;

                    return (Boolean)SCenabledField.GetValue(null);
                }
            }

            private FieldInfo SCTrackedBodiesField;

            /// <summary>
            /// Get the TrackedBodies dictionary
            /// </summary>
            /// <returns>TrackedBodies dictionary</returns>
            public Dictionary<CelestialBody, bool> TrackedBodies
            {
                get
                {
                    if (SCTrackedBodiesField == null)
                        return new Dictionary<CelestialBody, bool>();

                    return (Dictionary<CelestialBody, bool>)SCTrackedBodiesField.GetValue(null);
                }
            }

            private FieldInfo SCResearchStateField;

            /// <summary>
            /// Get the ResearchState Dictionary
            /// </summary>
            /// <returns>ResearchState dictionary</returns>
            public Dictionary<CelestialBody, int> ResearchState
            {
                get
                {
                    if (SCResearchStateField == null)
                        return new Dictionary<CelestialBody, int>();

                    return (Dictionary<CelestialBody, int>)SCResearchStateField.GetValue(null);
                }
            }

            #region Methods

            private MethodInfo ResearchMethod;

            /// <summary>
            /// Add Research points to a celstialbody
            /// </summary>
            /// <param name="body">The celestialbody</param>
            /// /// <param name="researchToAdd">How much research to add for the celestialbody</param>
            /// <returns>Bool indicating Success of call</returns>
            internal bool Research(CelestialBody body, int researchToAdd)
            {
                try
                {
                    return (bool)ResearchMethod.Invoke(APIactualRBSC, new Object[] { body, researchToAdd });
                }
                catch (Exception ex)
                {
                    LogFormatted("Unable to invoke Research Method");
                    LogFormatted("Exception: {0}", ex);
                    return false;
                    //throw;
                }
            }

            private MethodInfo LaunchResearchPlanMethod;

            /// <summary>
            /// Start a Researchlan for a celestialbody
            /// </summary>
            /// <param name="cb">The celestialbody</param>
            /// <returns>Bool indicating Success of call</returns>
            internal bool LaunchResearchPlan(CelestialBody cb)
            {
                try
                {
                    LaunchResearchPlanMethod.Invoke(APIactualRBSC, new Object[] { cb });
                    return true;
                }
                catch (Exception ex)
                {
                    LogFormatted("Unable to invoke LaunchResearchPlan Method");
                    LogFormatted("Exception: {0}", ex);
                    return false;
                    //throw;
                }
            }

            private MethodInfo StopResearchPlanMethod;

            /// <summary>
            /// Stop Research plan for a celestialbody
            /// </summary>
            /// <param name="cb">The celestialbody</param>
            /// <returns>Bool indicating success of call</returns>
            internal bool StopResearchPlan(CelestialBody cb)
            {
                try
                {
                    StopResearchPlanMethod.Invoke(APIactualRBSC, new Object[] { cb });
                    return true;
                }
                catch (Exception ex)
                {
                    LogFormatted("Unable to invoke StopResearchPlan Method");
                    LogFormatted("Exception: {0}", ex);
                    return false;
                    //throw;
                }
            }

            private MethodInfo LoadBodyLookMethod;

            /// <summary>
            /// Load Body Look
            /// </summary>
            /// <returns>Bool indicating success of call</returns>
            internal bool LoadBodyLook()
            {
                try
                {
                    LoadBodyLookMethod.Invoke(APIactualRBSC, null);
                    return true;
                }
                catch (Exception ex)
                {
                    LogFormatted("Unable to invoke StopResearchPlan Method");
                    LogFormatted("Exception: {0}", ex);
                    return false;
                    //throw;
                }
            }

            #endregion Methods
        }

        /// <summary>
        /// The Type that is an analogue of the real ResearchBodies. This lets you access all the API-able properties and Methods of ModuleTrackBodies
        /// </summary>
        public class ModuleTrackBodies
        {
            internal ModuleTrackBodies(Object a)
            {
                //store the actual object
                APIactualRBFL = a;

                //these sections get and store the reflection info and actual objects where required. Later in the properties we then read the values from the actual objects
                //for events we also add a handler

                //WORK OUT THE STUFF WE NEED TO HOOK FOR PEOPLE HERE

                LogFormatted("Getting enabled field");
                FLenabledField = RBFLAPIType.GetField("enable", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
                LogFormatted_DebugOnly("Success: " + (FLenabledField != null));

                LogFormatted("Getting TrackedBodies field");
                FLTrackedBodiesField = RBFLAPIType.GetField("TrackedBodies", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
                LogFormatted_DebugOnly("Success: " + (FLTrackedBodiesField != null));

                LogFormatted("Getting TrackedBodies field");
                FLResearchStateField = RBFLAPIType.GetField("ResearchState", BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
                LogFormatted_DebugOnly("Success: " + (FLResearchStateField != null));

                LogFormatted("Getting TrackedBodies field");
                FLScienceRewardField = RBFLAPIType.GetField("scienceReward", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
                LogFormatted_DebugOnly("Success: " + (FLScienceRewardField != null));

            }

            private Object APIactualRBFL;

            private FieldInfo FLenabledField;

            /// <summary>
            /// Whether the enabled field is set
            /// </summary>
            /// <returns>Bool value of enabled field</returns>
            public Boolean enabled
            {
                get
                {
                    if (FLenabledField == null)
                        return false;

                    return (Boolean)FLenabledField.GetValue(APIactualRBFL);
                }
            }

            private FieldInfo FLTrackedBodiesField;

            /// <summary>
            /// Get the TrackedBodies dictionary
            /// </summary>
            /// <returns>TrackedBodies dictionary</returns>
            public Dictionary<CelestialBody, bool> TrackedBodies
            {
                get
                {
                    if (FLTrackedBodiesField == null)
                        return new Dictionary<CelestialBody, bool>();

                    return (Dictionary<CelestialBody, bool>)FLTrackedBodiesField.GetValue(APIactualRBFL);
                }
            }

            private FieldInfo FLResearchStateField;

            /// <summary>
            /// Get the ResearchState Dictionary
            /// </summary>
            /// <returns>ResearchState dictionary</returns>
            public Dictionary<CelestialBody, int> ResearchState
            {
                get
                {
                    if (FLResearchStateField == null)
                        return new Dictionary<CelestialBody, int>();

                    return (Dictionary<CelestialBody, int>)FLResearchStateField.GetValue(APIactualRBFL);
                }
            }

            private FieldInfo FLScienceRewardField;

            /// <summary>
            /// The Science Reward field
            /// </summary>
            /// <returns>int value of ScienceReward field or 0</returns>
            public int ScienceReward
            {
                get
                {
                    if (FLScienceRewardField == null)
                        return 0;

                    return (int)FLScienceRewardField.GetValue(APIactualRBFL);
                }
            }

        }

        /// <summary>
        /// The Type that is an analogue of the real ResearchBodies. This lets you access all the API-able properties and Methods of Database
        /// </summary>
        public class RBDBAPI
        {
            internal RBDBAPI(Object a)
            {
                //store the actual object
                APIactualRBDB = a;

                //these sections get and store the reflection info and actual objects where required. Later in the properties we then read the values from the actual objects
                //for events we also add a handler

                //WORK OUT THE STUFF WE NEED TO HOOK FOR PEOPLE HERE

                LogFormatted_DebugOnly("Getting enableInSandbox field");
                DBenableInSandboxField = RBDBAPIType.GetField("enableInSandbox", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
                LogFormatted_DebugOnly("Success: " + (DBenableInSandboxField != null));

                LogFormatted_DebugOnly("Getting DiscoveryMessage field");
                DBDiscoveryMessageField = RBDBAPIType.GetField("DiscoveryMessage", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
                LogFormatted_DebugOnly("Success: " + (DBDiscoveryMessageField != null));

            }

            private Object APIactualRBDB;

            private FieldInfo DBenableInSandboxField;

            /// <summary>
            /// If ResearchBodies is enabled in sandbox mode
            /// </summary>
            /// <returns>bool value of enableInSandbox field</returns>
            public Boolean enableInSandbox
            {
                get
                {
                    if (DBenableInSandboxField == null)
                        return false;

                    return (Boolean)DBenableInSandboxField.GetValue(null);
                }
            }

            private FieldInfo DBDiscoveryMessageField;

            /// <summary>
            /// DiscoveryMessage dictionary
            /// </summary>
            /// <returns>the DiscoveryMessage dictionary</returns>
            public Dictionary<string, string> DiscoveryMessage
            {
                get
                {
                    if (DBDiscoveryMessageField == null)
                        return new Dictionary<string, string>();

                    return (Dictionary<string, string>)DBDiscoveryMessageField.GetValue(null);
                }
            }

        }

        #region Logging Stuff

        /// <summary>
        /// Some Structured logging to the debug file - ONLY RUNS WHEN TST Debug mode is on
        /// </summary>
        /// <param name="Message">Text to be printed - can be formatted as per String.format</param>
        /// <param name="strParams">Objects to feed into a String.format</param>
        internal static void LogFormatted_DebugOnly(String Message, params Object[] strParams)
        {
            TSTSettings TSTsettings = TSTMstStgs.Instance.TSTsettings;
            if (TSTsettings.debugging)
                LogFormatted(Message, strParams);
        }

        /// <summary>
        /// Some Structured logging to the debug file
        /// </summary>
        /// <param name="Message">Text to be printed - can be formatted as per String.format</param>
        /// <param name="strParams">Objects to feed into a String.format</param>
        internal static void LogFormatted(String Message, params Object[] strParams)
        {
            Message = String.Format(Message, strParams);
            String strMessageLine = String.Format("{0},{2}-{3},{1}",
                DateTime.Now, Message, Assembly.GetExecutingAssembly().GetName().Name,
                MethodBase.GetCurrentMethod().DeclaringType.Name);
            Debug.Log(strMessageLine);
        }

        #endregion Logging Stuff
    }
}


text:
'use strict';

const constants = require('./../constants/zhihu');
const superagent = require('superagent');
const parser = require('./../parsers/user/index');
const logger = require('log4js').getLogger('userSpider');

let session = {};

function setSession(_session) {
  session = _session;
}

function resolveUser(userName) {
  return new Promise((resolve, reject) => {
    let url = constants.url.userProfile(userName);
    logger.debug(`Getting user from ${url}...`);
    superagent
      .get(url)
      .set(session.getHttpHeader())
      .end((err, res) => {
        if (err) {
          reject(err);
        } else {
          parser
            .fromHtml(res.text)
            .then((user) => {
              user.id = userName;
              resolve(user);
            })
            .catch((e) => {
              reject(e);
            });
        }
      });
  });
}

module.exports = { setSession, resolveUser };

redpajama_set_name: RedPajamaGithub


text:
layout: post
title: "Global Game Jam 2014"
date: 2014-01-28 11:00
author: engin.polat
comments: true
category: [Etkinlik]
tags: [etkinliklerim, ggj, igda, seminer]
---
**Global Game Jam 2014** etkinliği *24 Ocak 2014* - *26 Ocak 2014* tarihleri arasında *İzmir Ekonomi Üniversitesi Konferans Salonu*'nda gerçekleştirildi.

Ben de **konuşmacı** , **mentor** ve **juri üyesi** sıfatları ile etkinliğe katıldım ve açıkçası çok keyifli zaman geçirdim.

***Global Game Jam nedir?***

*Global Game Jam*, **IGDA** (*International Game Developers Association* - *Uluslararası Oyun Geliştiricileri Derneği*) *Eğitim Odak Grubu*'nun yönlendirmesiyle ortaya çıkan, tüm dünyada eş zamanlı gerçekleştirilen bir oyun geliştirme etkinliğidir.

GGJ dünyada oyun geliştirilmesi amacıyla birçok *öğrenciyi*, *profesyoneli* ve *akademisyeni* bir araya getiren dünya genelindeki en büyük oyun geliştirme organizasyonudur.

GGJ 2014 etkinliğinde, dünya genelinde **72 ülkede** *488 etkinlik alanında* **23198 katılımcı** ile *4290 oynanabilir oyun* yalnızca 48 saat içerisinde geliştirilmiştir. GGJ etkinliğine ev sahipliği yapan etkinlik merkezleri yerel oyun sektörünün gelişmesine katkı sağlarken, katılımcılara çeşitli açılardan faydalar sağlamaktadır.

![](/assets/uploads/2014/01/GlobalGameJam2014.jpg)


text:
package ie.rkie.sm.service;

import ie.rkie.sm.db.Game;

public interface TokenFactory {

	String createToken(Game game);

}


text:
package org.apache.commons.vfs2.provider.sftp;

final class Utils {

    private Utils() {
        // never
    }

    static byte[] clone(final byte[] array) {
        return array != null ? array.clone() : null;
    }

}


text:
package topoutil

import "github.com/go-distributed/meritop"

func IsParent(t meritop.Topology, epoch, taskID uint64) bool {
	for _, id := range t.GetParents(epoch) {
		if taskID == id {
			return true
		}
	}
	return false
}

func IsChild(t meritop.Topology, epoch, taskID uint64) bool {
	for _, id := range t.GetChildren(epoch) {
		if taskID == id {
			return true
		}
	}
	return false
}


text:
const localStore = store => next => action => {
  let result = next(action)
  localStorage.setItem('appstate', JSON.stringify(store.getState()))
  return result
}

export default localStore

export const hydrateState = () => {
  return JSON.parse(localStorage.getItem('appstate'))
}


text:
import { combineReducers } from 'redux';

export function getLogOnRingingReducer(types) {
  return (state = true, { type, logOnRinging }) => {
    if (type === types.setLogOnRinging) return !!logOnRinging;
    return state;
  };
}

export function getAutoLogReducer(types, initialState = true) {
  return (state = initialState, { type, autoLog }) => {
    if (type === types.setAutoLog) return !!autoLog;
    return state;
  };
}

/* istanbul ignore next */
export default function getDataReducer(types, initialState = {}) {
  return combineReducers({
    autoLog: getAutoLogReducer(types, initialState.autoLog),
    logOnRinging: getLogOnRingingReducer(types),
  });
}


text:
// Copyright 2007-2012 Chris Patterson, Dru Sellers, Travis Smith, et. al.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use
// this file except in compliance with the License. You may obtain a copy of the
// License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.
namespace Topshelf.Logging
{
    using System;
    using System.IO;
    using log4net;
    using log4net.Config;

    public class Log4NetLogWriterFactory :
        LogWriterFactory
    {
        private static readonly System.Reflection.Assembly _callingAssembly = typeof(Log4NetLogWriterFactory).Assembly;

        public LogWriter Get(string name)
        {
            return new Log4NetLogWriter(LogManager.GetLogger(_callingAssembly, name));
        }

        public void Shutdown()
        {
            LogManager.Shutdown();
        }

        public static void Use()
        {
            HostLogger.UseLogger(new Log4NetLoggerConfigurator(null));
        }

        public static void Use(string file)
        {
            HostLogger.UseLogger(new Log4NetLoggerConfigurator(file));
        }

        public static void Use(string file, bool watch)
        {
            HostLogger.UseLogger(new Log4NetLoggerConfigurator(file, watch));
        }

        [Serializable]
        public class Log4NetLoggerConfigurator :
            HostLoggerConfigurator
        {
            readonly string _file;
            readonly bool _watch;

            public Log4NetLoggerConfigurator(string file)
              : this(file, false)
            {
            }

            public Log4NetLoggerConfigurator(string file, bool watch)
            {
                _file = file;
                _watch = watch;
            }

            public LogWriterFactory CreateLogWriterFactory()
            {
                if (!string.IsNullOrEmpty(_file))
                {
                    string file = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, _file);
                    var configFile = new FileInfo(file);
                    if (configFile.Exists)
                    {
                        if (_watch)
                        {
                            XmlConfigurator.ConfigureAndWatch(LogManager.GetRepository(_callingAssembly), configFile);
                        }
                        else
                        {
                            XmlConfigurator.Configure(LogManager.GetRepository(_callingAssembly), configFile);
                        }
                    }
                }

                return new Log4NetLogWriterFactory();
            }
        }
    }
}


text:
package com.saibi.ereader.fragments;

import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.FrameLayout;
import android.widget.GridView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ProgressBar;
import android.widget.TextView;

/**
 * Based on {@link android.app.ListFragment} but adapted for {@link GridView}.
 */
public class CustomGridFragment extends Fragment {
	static final int INTERNAL_EMPTY_ID = 0x00ff0001;
	static final int INTERNAL_PROGRESS_CONTAINER_ID = 0x00ff0002;
	static final int INTERNAL_LIST_CONTAINER_ID = 0x00ff0003;

	final private Handler mHandler = new Handler();

	final private Runnable mRequestFocus = new Runnable() {
		@Override
		public void run() {
			mGrid.focusableViewAvailable(mGrid);
		}
	};

	final private AdapterView.OnItemClickListener mOnClickListener = new AdapterView.OnItemClickListener() {
		@Override
		public void onItemClick(AdapterView<?> parent, View v, int position,
				long id) {
			onGridItemClick((GridView) parent, v, position, id);
		}
	};

	/**
	 * Custom GridView
	 */
	private GridView mCustomGridView;

	ListAdapter mAdapter;
	GridView mGrid;
	View mEmptyView;
	TextView mStandardEmptyView;
	View mProgressContainer;
	View mGridContainer;
	CharSequence mEmptyText;
	boolean mGridShown;

	public CustomGridFragment() {
	}

	/**
	 * Provide default implementation to return a simple grid view. Subclasses
	 * can override to replace with their own layout. If doing so, the returned
	 * view hierarchy must have a GridView whose id is
	 * {@link android.R.id#list android.R.id.list} and can optionally have a
	 * sibling view id {@link android.R.id#empty android.R.id.empty} that is to
	 * be shown when the grid is empty.
	 *
	 *

	 * If you are overriding this method with your own custom content, consider
	 * including the standard layout {@link android.R.layout#list_content} in
	 * your layout file, so that you continue to retain all of the standard
	 * behavior of ListFragment. In particular, this is currently the only way
	 * to have the built-in indeterminant progress state be shown.
	 */
	@SuppressWarnings("deprecation")
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		final Context context = getActivity();

		FrameLayout root = new FrameLayout(context);

		// ------------------------------------------------------------------

		LinearLayout pframe = new LinearLayout(context);
		pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
		pframe.setOrientation(LinearLayout.VERTICAL);
		pframe.setVisibility(View.GONE);
		pframe.setGravity(Gravity.CENTER);

		ProgressBar progress = new ProgressBar(context, null,
				android.R.attr.progressBarStyleLarge);
		pframe.addView(progress, new FrameLayout.LayoutParams(
				ViewGroup.LayoutParams.WRAP_CONTENT,
				ViewGroup.LayoutParams.WRAP_CONTENT));

		root.addView(pframe, new FrameLayout.LayoutParams(
				ViewGroup.LayoutParams.FILL_PARENT,
				ViewGroup.LayoutParams.FILL_PARENT));

		// ------------------------------------------------------------------

		FrameLayout lframe = new FrameLayout(context);
		lframe.setId(INTERNAL_LIST_CONTAINER_ID);

		TextView tv = new TextView(getActivity());
		tv.setId(INTERNAL_EMPTY_ID);
		tv.setGravity(Gravity.CENTER);
		lframe.addView(tv, new FrameLayout.LayoutParams(
				ViewGroup.LayoutParams.FILL_PARENT,
				ViewGroup.LayoutParams.FILL_PARENT));

		GridView gv;

		/*
		 * Custom ListView
		 */
		if (null == mCustomGridView) {
			gv = new GridView(getActivity());
		} else {
			gv = mCustomGridView;
		}
		gv.setId(android.R.id.list);
		gv.setDrawSelectorOnTop(false);
		lframe.addView(gv, new FrameLayout.LayoutParams(
				ViewGroup.LayoutParams.FILL_PARENT,
				ViewGroup.LayoutParams.FILL_PARENT));

		root.addView(lframe, new FrameLayout.LayoutParams(
				ViewGroup.LayoutParams.FILL_PARENT,
				ViewGroup.LayoutParams.FILL_PARENT));

		// ------------------------------------------------------------------

		root.setLayoutParams(new FrameLayout.LayoutParams(
				ViewGroup.LayoutParams.FILL_PARENT,
				ViewGroup.LayoutParams.FILL_PARENT));

		return root;
	}

	/**
	 * Attach to grid view once the view hierarchy has been created.
	 */
	@Override
	public void onViewCreated(View view, Bundle savedInstanceState) {
		super.onViewCreated(view, savedInstanceState);
		ensureGrid();
	}

	/**
	 * Detach from {@link GridView}
	 */
	@Override
	public void onDestroyView() {
		mHandler.removeCallbacks(mRequestFocus);
		mGrid = null;
		mGridShown = false;
		mEmptyView = mProgressContainer = mGridContainer = null;
		mStandardEmptyView = null;
		super.onDestroyView();
	}

	/**
	 * This method will be called when an item in the grid is selected.
	 * Subclasses should override. Subclasses can call
	 * getGridView().getItemAtPosition(position) if they need to access the data
	 * associated with the selected item.
	 *
	 * @param g
	 *            The {@link GridView} where the click happened
	 * @param v
	 *            The view that was clicked within the {@link GridView}
	 * @param position
	 *            The position of the view in the grid
	 * @param id
	 *            The row id of the item that was clicked
	 */
	public void onGridItemClick(GridView g, View v, int position, long id) {

	}

	/**
	 * Provide the cursor for the {@link GridView}.
	 */
	public void setGridAdapter(ListAdapter adapter) {
		final boolean hadAdapter = (mAdapter != null);
		mAdapter = adapter;
		if (mGrid != null) {
			mGrid.setAdapter(adapter);
			if (!mGridShown && !hadAdapter) {
				// The grid was hidden, and previously didn't have an
				// adapter. It is now time to show it.
				setGridShown(true, (getView().getWindowToken() != null));
			}
		}
	}

	/**
	 * Set the currently selected grid item to the specified position with the
	 * adapter's data
	 *
	 * @param position
	 *            int
	 */
	public void setSelection(int position) {
		ensureGrid();
		mGrid.setSelection(position);
	}

	/**
	 * Get the position of the currently selected grid item.
	 */
	public int getSelectedItemPosition() {
		ensureGrid();
		return mGrid.getSelectedItemPosition();
	}

	/**
	 * Get the cursor row ID of the currently selected grid item.
	 */
	public long getSelectedItemId() {
		ensureGrid();
		return mGrid.getSelectedItemId();
	}

	/**
	 * Get the activity's {@link GridView} widget.
	 */
	public GridView getGridView() {
		ensureGrid();
		return mGrid;
	}

	/**
	 * The default content for a ListFragment has a TextView that can be shown
	 * when the grid is empty. If you would like to have it shown, call this
	 * method to supply the text it should use.
	 */
	public void setEmptyText(CharSequence text) {
		ensureGrid();
		if (mStandardEmptyView == null) {
			throw new IllegalStateException(
					"Can't be used with a custom content view");
		}
		mStandardEmptyView.setText(text);
		if (mEmptyText == null) {
			mGrid.setEmptyView(mStandardEmptyView);
		}
		mEmptyText = text;
	}

	/**
	 * Seter for custom grid view resource
	 *
	 * @param resource
	 */
	public void setCustomGridView(int resource) {
		mCustomGridView = (GridView) getActivity().getLayoutInflater().inflate(
				resource, null);
	}

	/**
	 * Seter for custom grid view
	 *
	 * @param view
	 */
	public void setCustomGridView(GridView view) {
		mCustomGridView = view;
	}

	/**
	 * Control whether the grid is being displayed. You can make it not
	 * displayed if you are waiting for the initial data to show in it. During
	 * this time an indeterminant progress indicator will be shown instead.
	 *
	 *

	 * Applications do not normally need to use this themselves. The default
	 * behavior of ListFragment is to start with the grid not being shown, only
	 * showing it once an adapter is given with
	 * {@link #setGridAdapter(ListAdapter)}. If the grid at that point had not
	 * been shown, when it does get shown it will be do without the user ever
	 * seeing the hidden state.
	 *
	 * @param shown
	 *            If true, the grid view is shown; if false, the progress
	 *            indicator. The initial value is true.
	 */
	public void setGridShown(boolean shown) {
		setGridShown(shown, true);
	}

	/**
	 * Like {@link #setGridShown(boolean)}, but no animation is used when
	 * transitioning from the previous state.
	 */
	public void setGridShownNoAnimation(boolean shown) {
		setGridShown(shown, false);
	}

	/**
	 * Control whether the grid is being displayed. You can make it not
	 * displayed if you are waiting for the initial data to show in it. During
	 * this time an indeterminant progress indicator will be shown instead.
	 *
	 * @param shown
	 *            If true, the grid view is shown; if false, the progress
	 *            indicator. The initial value is true.
	 * @param animate
	 *            If true, an animation will be used to transition to the new
	 *            state.
	 */
	private void setGridShown(boolean shown, boolean animate) {
		ensureGrid();
		if (mProgressContainer == null) {
			throw new IllegalStateException(
					"Can't be used with a custom content view");
		}
		if (mGridShown == shown) {
			return;
		}
		mGridShown = shown;
		if (shown) {
			if (animate) {
				mProgressContainer.startAnimation(AnimationUtils.loadAnimation(
						getActivity(), android.R.anim.fade_out));
				mGridContainer.startAnimation(AnimationUtils.loadAnimation(
						getActivity(), android.R.anim.fade_in));
			} else {
				mProgressContainer.clearAnimation();
				mGridContainer.clearAnimation();
			}
			mProgressContainer.setVisibility(View.GONE);
			mGridContainer.setVisibility(View.VISIBLE);
		} else {
			if (animate) {
				mProgressContainer.startAnimation(AnimationUtils.loadAnimation(
						getActivity(), android.R.anim.fade_in));
				mGridContainer.startAnimation(AnimationUtils.loadAnimation(
						getActivity(), android.R.anim.fade_out));
			} else {
				mProgressContainer.clearAnimation();
				mGridContainer.clearAnimation();
			}
			mProgressContainer.setVisibility(View.VISIBLE);
			mGridContainer.setVisibility(View.GONE);
		}
	}

	/**
	 * Get the ListAdapter associated with this activity's {@link GridView}.
	 */
	public ListAdapter getGridAdapter() {
		return mAdapter;
	}

	private void ensureGrid() {
		if (mGrid != null) {
			return;
		}
		View root = getView();
		if (root == null) {
			throw new IllegalStateException("Content view not yet created");
		}
		if (root instanceof GridView) {
			mGrid = (GridView) root;
		} else {
			mStandardEmptyView = (TextView) root
					.findViewById(INTERNAL_EMPTY_ID);
			if (mStandardEmptyView == null) {
				mEmptyView = root.findViewById(android.R.id.empty);
			} else {
				mStandardEmptyView.setVisibility(View.GONE);
			}
			mProgressContainer = root
					.findViewById(INTERNAL_PROGRESS_CONTAINER_ID);
			mGridContainer = root.findViewById(INTERNAL_LIST_CONTAINER_ID);
			View rawGridView = root.findViewById(android.R.id.list);
			if (!(rawGridView instanceof GridView)) {
				if (rawGridView == null) {
					throw new RuntimeException(
							"Your content must have a GridView whose id attribute is "
									+ "'android.R.id.list'");
				}
				throw new RuntimeException(
						"Content has view with id attribute 'android.R.id.list' "
								+ "that is not a GridView class");
			}
			mGrid = (GridView) rawGridView;
			if (mEmptyView != null) {
				mGrid.setEmptyView(mEmptyView);
			} else if (mEmptyText != null) {
				mStandardEmptyView.setText(mEmptyText);
				mGrid.setEmptyView(mStandardEmptyView);
			}
		}
		mGridShown = true;
		mGrid.setOnItemClickListener(mOnClickListener);
		if (mAdapter != null) {
			ListAdapter adapter = mAdapter;
			mAdapter = null;
			setGridAdapter(adapter);
		} else {
			// We are starting without an adapter, so assume we won't
			// have our data right away and start with the progress indicator.
			if (mProgressContainer != null) {
				setGridShown(false, false);
			}
		}
		mHandler.post(mRequestFocus);
	}
}


text:
using System;
using Vanderbilt.Biostatistics.Wfccm2;

namespace ExpressionEvaluator.Procedures.Functions
{
    internal class Days : Function
    {
        public Days(int precedance)
            : base("days", precedance, 1, false)
        {
            _name2 = "Days";
            DecimalTimespan = x => new TimeSpan((long)(x * TimeSpan.TicksPerDay));
        }
    }
}