public void SetEnabledState(System.Func<bool> onState) {

			this.onState = onState;
			this.oldState = this.onState();
			this.onStateActive = true;

		}
 public void RunFuncUntilSuccess(Func<bool> Func, int Delay, int MaxDelay)
 {
     _maxTicks = Environment.TickCount + MaxDelay;
     _func = Func;
     _timer.Interval = Delay;
     _timer.Tick += Tick;
     _timer.Start();
 }
 static SorryAboutThisHackToGetTransactionsFromNH()
 {
   FieldInfo field = typeof(AdoTransaction).GetField("trans", BindingFlags.Instance | BindingFlags.NonPublic);
   if (field == null) throw new ArgumentException();
   _extractAdoTransaction = (nh) => {
     return (IDbTransaction)field.GetValue(nh);
   };
 }
 static ViewModelLocator()
 {
     TransformName = delegate (string typeName, bool includeInterfaces) {
         System.Func<string, string> func;
         if (includeInterfaces)
         {
             func = r => r;
         }
         else
         {
             string interfacegrpregex = @"\${" + InterfaceCaptureGroupName + "}$";
             func = r => Regex.IsMatch(r, interfacegrpregex) ? string.Empty : r;
         }
         return from n in NameTransformer.Transform(typeName, func)
             where n != string.Empty
             select n;
     };
     LocateTypeForViewType = delegate (Type viewType, bool searchForInterface) {
         string fullName = viewType.FullName;
         IEnumerable<string> source = TransformName(fullName, searchForInterface);
         Type type = (from n in source
             join t in from a in AssemblySource.Instance select a.GetExportedTypes() on n equals t.FullName
             select t).FirstOrDefault<Type>();
         if (type == null)
         {
             Log.Warn("View Model not found. Searched: {0}.", new object[] { string.Join(", ", source.ToArray<string>()) });
         }
         return type;
     };
     LocateForViewType = delegate (Type viewType) {
         Type type = LocateTypeForViewType(viewType, false);
         if (type != null)
         {
             object obj2 = IoC.GetInstance(type, null);
             if (obj2 != null)
             {
                 return obj2;
             }
         }
         type = LocateTypeForViewType(viewType, true);
         return (type != null) ? IoC.GetInstance(type, null) : null;
     };
     LocateForView = delegate (object view) {
         if (view == null)
         {
             return null;
         }
         FrameworkElement element = view as FrameworkElement;
         if ((element != null) && (element.DataContext != null))
         {
             return element.DataContext;
         }
         return LocateForViewType(view.GetType());
     };
     ConfigureTypeMappings(new TypeMappingConfiguration());
 }
		public override void OnDeinit() {

			base.OnDeinit();

			this.onState = null;

			if (this.button != null) this.button.onClick.RemoveListener(this.OnClick);
			this.callback.RemoveAllListeners();
			this.callbackButton.RemoveAllListeners();

		}
示例#6
0
文件: HTTPServer.cs 项目: vls/hp2p
 public HttpProcessor(EndPoint endPoint, System.Func<EndPoint, Hashtable, string, Response> processFunc, Socket s, string request)
 {
     _socket = s;
     _endPoint = endPoint;
     _processFunc = processFunc;
     _requestString = request;
     supportMethodDict = new Dictionary<string, object>()
                             {
                                 {"GET", null},
                                 {"POST", null}
                             };
 }
示例#7
0
	public UIAnimation( UIObject sprite, float duration, UIAnimationProperty aniProperty, Color startColor, Color targetColor, System.Func<float, float> ease )
	{
		this.sprite = sprite;
		this.duration = duration;
		_aniProperty = aniProperty;
		this.ease = ease;
		
		this.startColor = startColor;
		this.targetColor = targetColor;
		
		_running = true;
		startTime = Time.realtimeSinceStartup;
	}
示例#8
0
    public UIAnimation( UIObject sprite, float duration, UIAnimationProperty aniProperty, float startFloat, float targetFloat, System.Func<float, float> ease )
    {
        this.sprite = sprite;
        this.duration = duration;
        _aniProperty = aniProperty;
        this.ease = ease;

        this.targetFloat = targetFloat;
        this.startFloat = startFloat;

        _running = true;
        startTime = Time.time;
    }
示例#9
0
    public UIAnimation(UIObject sprite, float duration, UIAnimationProperty aniProperty, float startFloat, float targetFloat, System.Func<float, float> ease, bool affectedByTimeScale = true)
    {
        this.sprite = sprite;
        this.duration = duration;
        _aniProperty = aniProperty;
        this.ease = ease;
        this.affectedByTimeScale = affectedByTimeScale;
        this.targetFloat = targetFloat;
        this.startFloat = startFloat;

        _running = true;
        startTime = affectedByTimeScale ? Time.time : Time.realtimeSinceStartup;
    }
示例#10
0
	public UIAnimation( UIObject sprite, float duration, UIAnimationProperty aniProperty, Vector3 start, Vector3 target, System.Func<float, float> ease )
	{
		this.sprite = sprite;
		this.duration = duration;
		_aniProperty = aniProperty;
		this.ease = ease;
		
		this.target = target;
		this.start = start;
		
		_running = true;
		startTime = Time.realtimeSinceStartup;
	}
		public override void OnDeinit() {

			base.OnDeinit();

			this.onState = null;

			if (this.button != null) this.button.onClick.RemoveListener(this.OnClick);
			this.callback.RemoveAllListeners();
			this.callbackButton.RemoveAllListeners();

			#if FLOW_PLUGIN_HEATMAP
			//this.button.onClick.RemoveListener(this.HeatmapSendComponentClick);
			#endif

		}
示例#12
0
 static View()
 {
     GetFirstNonGeneratedView = delegate (object view) {
         DependencyObject obj2 = view as DependencyObject;
         if (obj2 == null)
         {
             return view;
         }
         if ((bool) obj2.GetValue(IsGeneratedProperty))
         {
             if (obj2 is ContentControl)
             {
                 return ((ContentControl) obj2).Content;
             }
             Type type = obj2.GetType();
             ContentPropertyAttribute attribute = type.GetAttributes<ContentPropertyAttribute>(true).FirstOrDefault<ContentPropertyAttribute>() ?? DefaultContentProperty;
             return type.GetProperty(attribute.Name).GetValue(obj2, null);
         }
         return obj2;
     };
 }
示例#13
0
 static MessageBinder()
 {
     Dictionary<string, System.Func<ActionExecutionContext, object>> dictionary = new Dictionary<string, System.Func<ActionExecutionContext, object>>();
     dictionary.Add("$eventargs", c => c.EventArgs);
     dictionary.Add("$datacontext", c => c.Source.DataContext);
     dictionary.Add("$source", c => c.Source);
     dictionary.Add("$executioncontext", c => c);
     dictionary.Add("$view", c => c.View);
     SpecialValues = dictionary;
     Dictionary<Type, System.Func<object, object, object>> dictionary2 = new Dictionary<Type, System.Func<object, object, object>>();
     dictionary2.Add(typeof(DateTime), delegate (object value, object context) {
         DateTime time;
         DateTime.TryParse(value.ToString(), out time);
         return time;
     });
     CustomConverters = dictionary2;
     EvaluateParameter = delegate (string text, Type parameterType, ActionExecutionContext context) {
         System.Func<ActionExecutionContext, object> func;
         string key = text.ToLower(CultureInfo.InvariantCulture);
         return SpecialValues.TryGetValue(key, out func) ? func(context) : text;
     };
 }
示例#14
0
    /// <summary>
    /// Initializes the native function calls.
    /// </summary>
    void InitializeNativeFunctionCalls() {
#if !UNITY_EDITOR
        switch(listBehavior) {
        case SyncableListBehavior.HighNumber:
            setListMaxSize = _AmazonGCWSSetHighNumberListMaxSize; 
            getListMaxSize = _AmazonGCWSGetHighNumberListMaxSize;
            isListSet = _AmazonGCWSHighNumberListIsSet;
            addStringWithMetadataToList = _AmazonGCWSHighNumberListAddStringAndMetadataAsJSON;
            addStringToList = _AmazonGCWSHighNumberListAddString;
            getTimestampAtIndex = _AmazonGCWSGetHighNumberListTimestampAtIndex;
            getMetadataAtIndex = _AmazonGCWSGetHighNumberListMetadataAtIndex;
            getListCount = _AmazonGCWSGetHighNumberListCount;
            break;
        case SyncableListBehavior.LatestNumber:
            setListMaxSize = _AmazonGCWSSetLatestNumberListMaxSize; 
            getListMaxSize = _AmazonGCWSGetLatestNumberListMaxSize;
            isListSet = _AmazonGCWSLatestNumberListIsSet;
            addStringWithMetadataToList = _AmazonGCWSLatestNumberListAddStringAndMetadataAsJSON;
            addStringToList = _AmazonGCWSLatestNumberListAddString;
            getTimestampAtIndex = _AmazonGCWSGetLatestNumberListTimestampAtIndex;
            getMetadataAtIndex = _AmazonGCWSGetLatestNumberListMetadataAtIndex;
            getListCount = _AmazonGCWSGetLatestNumberListCount;
            break;
        case SyncableListBehavior.LowNumber:
            setListMaxSize = _AmazonGCWSSetLowNumberListMaxSize; 
            getListMaxSize = _AmazonGCWSGetLowNumberListMaxSize;
            isListSet = _AmazonGCWSLowNumberListIsSet;
            addStringWithMetadataToList = _AmazonGCWSLowNumberListAddStringAndMetadataAsJSON;
            addStringToList = _AmazonGCWSLowNumberListAddString;
            getTimestampAtIndex = _AmazonGCWSGetLowNumberListTimestampAtIndex;
            getMetadataAtIndex = _AmazonGCWSGetLowNumberListMetadataAtIndex;
            getListCount = _AmazonGCWSGetLowNumberListCount;
            break;
        case SyncableListBehavior.LatestString:
            setListMaxSize = _AmazonGCWSSetLatestStringListMaxSize; 
            getListMaxSize = _AmazonGCWSGetLatestStringListMaxSize;
            isListSet = _AmazonGCWSLatestStringListIsSet;
            addStringWithMetadataToList = _AmazonGCWSLatestStringListAddStringAndMetadataAsJSON;
            addStringToList = _AmazonGCWSLatestStringListAddString;
            getTimestampAtIndex = _AmazonGCWSGetLatestStringListTimestampAtIndex;
            getMetadataAtIndex = _AmazonGCWSGetLatestStringListMetadataAtIndex;
            getListCount = _AmazonGCWSGetLatestStringListCount;
            break;
        default:
            AGSClient.LogGameCircleError(string.Format("Unhandled Whispersync list behavior {0}",listBehavior.ToString()));
            break;
        }
#endif
    }
示例#15
0
    /// <summary>
    /// Initializes the native function calls.
    /// </summary>
    void InitializeNativeFunctionCalls() {
        // Does nothing in editor mode so these functions remain null.
#if !UNITY_EDITOR
        switch(listBehavior) {
        case SyncableListBehavior.HighNumber:
            addNumberAsInt = _AmazonGCWSNumberListAddHighInt;
            addNumberAsInt64 = _AmazonGCWSNumberListAddHighInt64;
            addNumberAsDouble = _AmazonGCWSNumberListAddHighDouble;
            addNumberAsIntWithMetadata = _AmazonGCWSNumberListAddHighIntJSONMetadata;
            addNumberAsInt64WithMetadata = _AmazonGCWSNumberListAddHighInt64JSONMetadata;
            addNumberAsDoubleWithMetadata = _AmazonGCWSNumberListAddHighDoubleJSONMetadata;
            getValueAtIndexAsInt = _AmazonGCWSGetHighNumberListElementValueAsInt;
            getValueAtIndexAsInt64 = _AmazonGCWSGetHighNumberListElementValueAsInt64;
            getValueAtIndexAsDouble = _AmazonGCWSGetHighNumberListElementValueAsDouble;
            getValueAtIndexAsString = _AmazonGCWSGetHighNumberListElementValueAsString;
            break;
        case SyncableListBehavior.LatestNumber:
            addNumberAsInt = _AmazonGCWSNumberListAddLatestInt;
            addNumberAsInt64 = _AmazonGCWSNumberListAddLatestInt64;
            addNumberAsDouble = _AmazonGCWSNumberListAddLatestDouble;
            addNumberAsIntWithMetadata = _AmazonGCWSNumberListAddLatestIntJSONMetadata;
            addNumberAsInt64WithMetadata = _AmazonGCWSNumberListAddLatestInt64JSONMetadata;
            addNumberAsDoubleWithMetadata = _AmazonGCWSNumberListAddLatestDoubleJSONMetadata;
            getValueAtIndexAsInt = _AmazonGCWSGetLatestNumberListElementValueAsInt;
            getValueAtIndexAsInt64 = _AmazonGCWSGetLatestNumberListElementValueAsInt64;
            getValueAtIndexAsDouble = _AmazonGCWSGetLatestNumberListElementValueAsDouble;
            getValueAtIndexAsString = _AmazonGCWSGetLatestNumberListElementValueAsString;
            break;
        case SyncableListBehavior.LowNumber:
            addNumberAsInt = _AmazonGCWSNumberListAddLowInt;
            addNumberAsInt64 = _AmazonGCWSNumberListAddLowInt64;
            addNumberAsDouble = _AmazonGCWSNumberListAddLowDouble;
            addNumberAsIntWithMetadata = _AmazonGCWSNumberListAddLowIntJSONMetadata;
            addNumberAsInt64WithMetadata = _AmazonGCWSNumberListAddLowInt64JSONMetadata;
            addNumberAsDoubleWithMetadata = _AmazonGCWSNumberListAddLowDoubleJSONMetadata;
            getValueAtIndexAsInt = _AmazonGCWSGetLowNumberListElementValueAsInt;
            getValueAtIndexAsInt64 = _AmazonGCWSGetLowNumberListElementValueAsInt64;
            getValueAtIndexAsDouble = _AmazonGCWSGetLowNumberListElementValueAsDouble;
            getValueAtIndexAsString = _AmazonGCWSGetLowNumberListElementValueAsString;
            break;
        default:
            AGSClient.LogGameCircleError(string.Format("Unhandled Whispersync list behavior {0}",listBehavior.ToString()));
            break;
        }
#endif
    }
 static ViewModelBinder()
 {
     BindProperties = delegate (IEnumerable<FrameworkElement> namedElements, Type viewModelType) {
         List<FrameworkElement> list = new List<FrameworkElement>();
         foreach (FrameworkElement element in namedElements)
         {
             string str = element.Name.Trim(new char[] { '_' });
             string[] strArray = str.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries);
             PropertyInfo propertyCaseInsensitive = viewModelType.GetPropertyCaseInsensitive(strArray[0]);
             Type propertyType = viewModelType;
             for (int j = 1; (j < strArray.Length) && (propertyCaseInsensitive != null); j++)
             {
                 propertyType = propertyCaseInsensitive.PropertyType;
                 propertyCaseInsensitive = propertyType.GetPropertyCaseInsensitive(strArray[j]);
             }
             if (propertyCaseInsensitive == null)
             {
                 list.Add(element);
                 Log.Info("Binding Convention Not Applied: Element {0} did not match a property.", new object[] { element.Name });
             }
             else
             {
                 ElementConvention elementConvention = ConventionManager.GetElementConvention(element.GetType());
                 if (elementConvention == null)
                 {
                     list.Add(element);
                     Log.Warn("Binding Convention Not Applied: No conventions configured for {0}.", new object[] { element.GetType() });
                 }
                 else if (elementConvention.ApplyBinding(propertyType, str.Replace('_', '.'), propertyCaseInsensitive, element, elementConvention))
                 {
                     Log.Info("Binding Convention Applied: Element {0}.", new object[] { element.Name });
                 }
                 else
                 {
                     Log.Info("Binding Convention Not Applied: Element {0} has existing binding.", new object[] { element.Name });
                     list.Add(element);
                 }
             }
         }
         return list;
     };
     BindActions = delegate (IEnumerable<FrameworkElement> namedElements, Type viewModelType) {
         MethodInfo[] methods = viewModelType.GetMethods();
         List<FrameworkElement> elementsToSearch = namedElements.ToList<FrameworkElement>();
         foreach (MethodInfo info in methods)
         {
             FrameworkElement item = elementsToSearch.FindName(info.Name);
             if (item == null)
             {
                 Log.Info("Action Convention Not Applied: No actionable element for {0}.", new object[] { info.Name });
             }
             else
             {
                 elementsToSearch.Remove(item);
                 System.Windows.Interactivity.TriggerCollection triggers = Interaction.GetTriggers(item);
                 if ((triggers != null) && (triggers.Count > 0))
                 {
                     Log.Info("Action Convention Not Applied: Interaction.Triggers already set on {0}.", new object[] { item.Name });
                 }
                 else
                 {
                     string attachText = info.Name;
                     ParameterInfo[] parameters = info.GetParameters();
                     if (parameters.Length > 0)
                     {
                         attachText = attachText + "(";
                         foreach (ParameterInfo info2 in parameters)
                         {
                             string name = info2.Name;
                             string key = "$" + name.ToLower();
                             if (MessageBinder.SpecialValues.ContainsKey(key))
                             {
                                 name = key;
                             }
                             attachText = attachText + name + ",";
                         }
                         attachText = attachText.Remove(attachText.Length - 1, 1) + ")";
                     }
                     Log.Info("Action Convention Applied: Action {0} on element {1}.", new object[] { info.Name, attachText });
                     Message.SetAttach(item, attachText);
                 }
             }
         }
         return elementsToSearch;
     };
     HandleUnmatchedElements = delegate (IEnumerable<FrameworkElement> elements, Type viewModelType) {
     };
     Bind = delegate (object viewModel, DependencyObject view, object context) {
         Log.Info("Binding {0} and {1}.", new object[] { view, viewModel });
         if ((bool) view.GetValue(Caliburn.Micro.Bind.NoContextProperty))
         {
             Caliburn.Micro.Action.SetTargetWithoutContext(view, viewModel);
         }
         else
         {
             Caliburn.Micro.Action.SetTarget(view, viewModel);
         }
         IViewAware aware = viewModel as IViewAware;
         if (aware != null)
         {
             Log.Info("Attaching {0} to {1}.", new object[] { view, aware });
             aware.AttachView(view, context);
         }
         if (!((bool) view.GetValue(ConventionsAppliedProperty)))
         {
             FrameworkElement element = View.GetFirstNonGeneratedView(view) as FrameworkElement;
             if (element != null)
             {
                 if (!ShouldApplyConventions(element))
                 {
                     Log.Info("Skipping conventions for {0} and {1}.", new object[] { element, viewModel });
                 }
                 else
                 {
                     Type type = viewModel.GetType();
                     IEnumerable<FrameworkElement> enumerable = BindingScope.GetNamedElements(element);
                     enumerable.Apply<FrameworkElement>(x => x.SetValue(View.IsLoadedProperty, element.GetValue(View.IsLoadedProperty)));
                     enumerable = BindActions(enumerable, type);
                     enumerable = BindProperties(enumerable, type);
                     HandleUnmatchedElements(enumerable, type);
                     view.SetValue(ConventionsAppliedProperty, true);
                 }
             }
         }
     };
 }
示例#17
0
 public Action(int delay, int interval, System.Func<long,bool> function)
 {
     _ticks = -delay;
     _function = function;
     _interval = Math.Max(1,interval);
 }
示例#18
0
 void RegisterTableType <T>(System.Func <ByteString, T> decodeFun)
 {
     RegisterType <T>(bytes => decodeFun(bytes));
 }
示例#19
0
 /// <summary>
 /// Metodo que construye una sola expresion con todas las restricciones de la lista
 /// </summary>
 /// <returns></returns>
 private Func<RoomSettings, bool> BuildConstraints()
 {
     constraints = constraintsList[0];
     for(int i=1;i<constraintsList.Count; i++)
     {
         constraints.And(constraintsList[i]);
     }
     return constraints;
 }
示例#20
0
 /// <summary>
 /// Get historical trades for the exchange
 /// </summary>
 /// <param name="callback">Callback for each set of trades. Return false to stop getting trades immediately.</param>
 /// <param name="symbol">Symbol to get historical data for</param>
 /// <param name="sinceDateTime">Optional date time to start getting the historical data at, null for the most recent data</param>
 public void GetHistoricalTrades(System.Func <IEnumerable <ExchangeTrade>, bool> callback, string symbol, DateTime?sinceDateTime = null) => GetHistoricalTradesAsync(callback, symbol, sinceDateTime).GetAwaiter().GetResult();
示例#21
0
        private void AddChildrenRecursive <T>(T parent, int depth, IList <T> newRows, System.Func <T, T> Copy) where T : TreeViewItem
        {
            if (parent.children == null)
            {
                return;
            }

            foreach (T child in parent.children)
            {
                var item = Copy(child);
                newRows.Add(child);

                if (child.hasChildren)
                {
                    if (IsExpanded(child.id))
                    {
                        AddChildrenRecursive(child, depth + 1, newRows, Copy);
                    }
                    else
                    {
                        item.children = CreateChildListForCollapsedParent();
                    }
                }
            }
        }
示例#22
0
 protected internal override GraphDatabaseService newDatabase(File storeDir, Config config, GraphDatabaseFacadeFactory.Dependencies dependencies)
 {
     System.Func <PlatformModule, AbstractEditionModule> factory = platformModule => new CommunityEditionModuleAnonymousInnerClass(this, platformModule);
     return((new GraphDatabaseFacadeFactory(DatabaseInfo.COMMUNITY, factory)).newFacade(storeDir, config, dependencies));
 }
 public GeneticAlgorithm(System.Func <Gene, int> fitnessFunction)
 {
     this.FitnessFunction = fitnessFunction;
     rng = new System.Random();
 }
示例#24
0
 public bool All(System.Func <int, int, bool> f)
 {
     return(blocks.Select((v, i) => new { v, i }).All(item => { return f(i2x(item.i), i2z(item.i)); }));
 }
示例#25
0
 public async Task <IEnumerable <object> > GetProdutoClienteSaidaPagination(int pageNumber, int pageSize, System.Func <ProdutoClienteSaida, int> orderByFunc, System.Func <ProdutoClienteSaida, bool> countFunc, int empresaId)
 {
     return
         (await
          _produtoClienteSaidaRepository.GetProdutoClienteSaidaPagination(pageNumber, pageSize, orderByFunc,
                                                                          countFunc, empresaId));
 }
示例#26
0
 CommandState ICommandHandler <BackspaceKeyCommandArgs> .GetCommandState(BackspaceKeyCommandArgs args, System.Func <CommandState> nextHandler)
 {
     AssertIsForeground();
     return(nextHandler());
 }
示例#27
0
 static void fill_accumulator(Accumulator acc, int x_steps, int y_steps, int z_steps, System.Func <double, double, double, int> f)
 {
     foreach (var x in range(x_steps))
     {
         foreach (var y in range(y_steps))
         {
             foreach (var z in range(z_steps))
             {
                 int rgbint = f(x, y, z);
                 acc.Increment(rgbint);
             }
         }
     }
 }
示例#28
0
 public DelegateCommand(System.Action execute, System.Func <bool> canExecute)
 {
     this.execute    = execute;
     this.canExecute = canExecute;
 }
 //-------------------------------------------------------------------------
 // creates an identifier for a single calendar
 private HolidayCalendarId(string normalizedName)
 {
     this.name             = normalizedName;
     this.hashCode_Renamed = normalizedName.GetHashCode();
     this.resolver         = (id, refData) => refData.queryValueOrNull(this);
 }
示例#30
0
 public DeploymentManagerFactory(System.Func<IDeploymentManager> factory)
 {
     _factory = factory;
 }
 // creates an identifier for a combined calendar
 private HolidayCalendarId(string normalizedName, System.Func <HolidayCalendarId, ReferenceData, HolidayCalendar> resolver)
 {
     this.name             = normalizedName;
     this.hashCode_Renamed = normalizedName.GetHashCode();
     this.resolver         = resolver;
 }
 public AccountItemMoney()
 {
     this.CurrencySymbolGetter = new System.Func<CurrencyType, Decimal, String>(this.getCurrencySymbolProxy);
 }
示例#33
0
        private static void RegisterServices(IKernel kernel)
        {
            var serverConfiguration = new ServerConfiguration();

            // Make sure %HOME% is correctly set
            EnsureHomeEnvironmentVariable();

            EnsureSiteBitnessEnvironmentVariable();

            IEnvironment environment = GetEnvironment();

            // Add various folders that never change to the process path. All child processes will inherit
            PrependFoldersToPath(environment);

            // Per request environment
            kernel.Bind <IEnvironment>().ToMethod(context => GetEnvironment(context.Kernel.Get <IDeploymentSettingsManager>()))
            .InRequestScope();

            // General
            kernel.Bind <HttpContextBase>().ToMethod(context => new HttpContextWrapper(HttpContext.Current))
            .InRequestScope();
            kernel.Bind <IServerConfiguration>().ToConstant(serverConfiguration);

            kernel.Bind <IBuildPropertyProvider>().ToConstant(new BuildPropertyProvider());

            System.Func <ITracer> createTracerThunk = () => GetTracer(environment, kernel);
            System.Func <ILogger> createLoggerThunk = () => GetLogger(environment, kernel);

            // First try to use the current request profiler if any, otherwise create a new one
            var traceFactory = new TracerFactory(() => TraceServices.CurrentRequestTracer ?? createTracerThunk());

            kernel.Bind <ITracer>().ToMethod(context => TraceServices.CurrentRequestTracer ?? NullTracer.Instance);
            kernel.Bind <ITraceFactory>().ToConstant(traceFactory);
            TraceServices.SetTraceFactory(createTracerThunk, createLoggerThunk);

            // Setup the deployment lock
            string lockPath           = Path.Combine(environment.SiteRootPath, Constants.LockPath);
            string deploymentLockPath = Path.Combine(lockPath, Constants.DeploymentLockFile);
            string statusLockPath     = Path.Combine(lockPath, Constants.StatusLockFile);
            string sshKeyLockPath     = Path.Combine(lockPath, Constants.SSHKeyLockFile);
            string hooksLockPath      = Path.Combine(lockPath, Constants.HooksLockFile);

            _deploymentLock = new DeploymentLockFile(deploymentLockPath, kernel.Get <ITraceFactory>());
            _deploymentLock.InitializeAsyncLocks();

            var statusLock = new LockFile(statusLockPath, kernel.Get <ITraceFactory>());
            var sshKeyLock = new LockFile(sshKeyLockPath, kernel.Get <ITraceFactory>());
            var hooksLock  = new LockFile(hooksLockPath, kernel.Get <ITraceFactory>());

            kernel.Bind <IOperationLock>().ToConstant(sshKeyLock).WhenInjectedInto <SSHKeyController>();
            kernel.Bind <IOperationLock>().ToConstant(statusLock).WhenInjectedInto <DeploymentStatusManager>();
            kernel.Bind <IOperationLock>().ToConstant(hooksLock).WhenInjectedInto <WebHooksManager>();
            kernel.Bind <IOperationLock>().ToConstant(_deploymentLock);

            var shutdownDetector = new ShutdownDetector();

            shutdownDetector.Initialize();

            IDeploymentSettingsManager noContextDeploymentsSettingsManager =
                new DeploymentSettingsManager(new XmlSettings.Settings(GetSettingsPath(environment)));

            TraceServices.TraceLevel = noContextDeploymentsSettingsManager.GetTraceLevel();

            var noContextTraceFactory = new TracerFactory(() => GetTracerWithoutContext(environment, noContextDeploymentsSettingsManager));

            kernel.Bind <IAnalytics>().ToMethod(context => new Analytics(context.Kernel.Get <IDeploymentSettingsManager>(),
                                                                         context.Kernel.Get <IServerConfiguration>(),
                                                                         noContextTraceFactory));

            // Trace unhandled (crash) exceptions.
            AppDomain.CurrentDomain.UnhandledException += (sender, args) =>
            {
                var ex = args.ExceptionObject as Exception;
                if (ex != null)
                {
                    kernel.Get <IAnalytics>().UnexpectedException(ex);
                }
            };

            // Trace shutdown event
            // Cannot use shutdownDetector.Token.Register because of race condition
            // with NinjectServices.Stop via WebActivator.ApplicationShutdownMethodAttribute
            Shutdown += () => TraceShutdown(environment, noContextDeploymentsSettingsManager);

            // LogStream service
            // The hooks and log stream start endpoint are low traffic end-points. Re-using it to avoid creating another lock
            var logStreamManagerLock = hooksLock;

            kernel.Bind <LogStreamManager>().ToMethod(context => new LogStreamManager(Path.Combine(environment.RootPath, Constants.LogFilesPath),
                                                                                      context.Kernel.Get <IEnvironment>(),
                                                                                      context.Kernel.Get <IDeploymentSettingsManager>(),
                                                                                      context.Kernel.Get <ITracer>(),
                                                                                      shutdownDetector,
                                                                                      logStreamManagerLock));

            kernel.Bind <InfoRefsController>().ToMethod(context => new InfoRefsController(t => context.Kernel.Get(t)))
            .InRequestScope();

            kernel.Bind <CustomGitRepositoryHandler>().ToMethod(context => new CustomGitRepositoryHandler(t => context.Kernel.Get(t)))
            .InRequestScope();

            // Deployment Service
            kernel.Bind <ISettings>().ToMethod(context => new XmlSettings.Settings(GetSettingsPath(environment)))
            .InRequestScope();
            kernel.Bind <IDeploymentSettingsManager>().To <DeploymentSettingsManager>()
            .InRequestScope();

            kernel.Bind <IDeploymentStatusManager>().To <DeploymentStatusManager>()
            .InRequestScope();

            kernel.Bind <ISiteBuilderFactory>().To <SiteBuilderFactory>()
            .InRequestScope();

            kernel.Bind <IWebHooksManager>().To <WebHooksManager>()
            .InRequestScope();

            ITriggeredJobsManager triggeredJobsManager = new TriggeredJobsManager(
                noContextTraceFactory,
                kernel.Get <IEnvironment>(),
                kernel.Get <IDeploymentSettingsManager>(),
                kernel.Get <IAnalytics>(),
                kernel.Get <IWebHooksManager>());

            kernel.Bind <ITriggeredJobsManager>().ToConstant(triggeredJobsManager)
            .InTransientScope();

            TriggeredJobsScheduler triggeredJobsScheduler = new TriggeredJobsScheduler(
                triggeredJobsManager,
                noContextTraceFactory,
                environment,
                kernel.Get <IAnalytics>());

            kernel.Bind <TriggeredJobsScheduler>().ToConstant(triggeredJobsScheduler)
            .InTransientScope();

            IContinuousJobsManager continuousJobManager = new ContinuousJobsManager(
                noContextTraceFactory,
                kernel.Get <IEnvironment>(),
                kernel.Get <IDeploymentSettingsManager>(),
                kernel.Get <IAnalytics>());

            OperationManager.SafeExecute(triggeredJobsManager.CleanupDeletedJobs);
            OperationManager.SafeExecute(continuousJobManager.CleanupDeletedJobs);

            kernel.Bind <IContinuousJobsManager>().ToConstant(continuousJobManager)
            .InTransientScope();

            kernel.Bind <ILogger>().ToMethod(context => GetLogger(environment, context.Kernel))
            .InRequestScope();

            kernel.Bind <IDeploymentManager>().To <DeploymentManager>()
            .InRequestScope();
            kernel.Bind <IAutoSwapHandler>().To <AutoSwapHandler>()
            .InRequestScope();
            kernel.Bind <ISSHKeyManager>().To <SSHKeyManager>()
            .InRequestScope();

            kernel.Bind <IRepositoryFactory>().ToMethod(context => _deploymentLock.RepositoryFactory = new RepositoryFactory(context.Kernel.Get <IEnvironment>(),
                                                                                                                             context.Kernel.Get <IDeploymentSettingsManager>(),
                                                                                                                             context.Kernel.Get <ITraceFactory>()))
            .InRequestScope();

            kernel.Bind <IApplicationLogsReader>().To <ApplicationLogsReader>()
            .InSingletonScope();

            // Git server
            kernel.Bind <IDeploymentEnvironment>().To <DeploymentEnvrionment>();

            kernel.Bind <IGitServer>().ToMethod(context => new GitExeServer(context.Kernel.Get <IEnvironment>(),
                                                                            _deploymentLock,
                                                                            GetRequestTraceFile(context.Kernel),
                                                                            context.Kernel.Get <IRepositoryFactory>(),
                                                                            context.Kernel.Get <IDeploymentEnvironment>(),
                                                                            context.Kernel.Get <IDeploymentSettingsManager>(),
                                                                            context.Kernel.Get <ITraceFactory>()))
            .InRequestScope();

            // Git Servicehook parsers
            kernel.Bind <IServiceHookHandler>().To <GenericHandler>().InRequestScope();
            kernel.Bind <IServiceHookHandler>().To <GitHubHandler>().InRequestScope();
            kernel.Bind <IServiceHookHandler>().To <BitbucketHandler>().InRequestScope();
            kernel.Bind <IServiceHookHandler>().To <BitbucketHandlerV2>().InRequestScope();
            kernel.Bind <IServiceHookHandler>().To <DropboxHandler>().InRequestScope();
            kernel.Bind <IServiceHookHandler>().To <CodePlexHandler>().InRequestScope();
            kernel.Bind <IServiceHookHandler>().To <CodebaseHqHandler>().InRequestScope();
            kernel.Bind <IServiceHookHandler>().To <GitlabHqHandler>().InRequestScope();
            kernel.Bind <IServiceHookHandler>().To <GitHubCompatHandler>().InRequestScope();
            kernel.Bind <IServiceHookHandler>().To <KilnHgHandler>().InRequestScope();
            kernel.Bind <IServiceHookHandler>().To <VSOHandler>().InRequestScope();
            kernel.Bind <IServiceHookHandler>().To <OneDriveHandler>().InRequestScope();

            // SiteExtensions
            kernel.Bind <ISiteExtensionManager>().To <SiteExtensionManager>().InRequestScope();

            // Functions
            kernel.Bind <IFunctionManager>().To <FunctionManager>().InRequestScope();

            // Command executor
            kernel.Bind <ICommandExecutor>().To <CommandExecutor>().InRequestScope();

            MigrateSite(environment, noContextDeploymentsSettingsManager);
            RemoveOldTracePath(environment);
            RemoveTempFileFromUserDrive(environment);

            // Temporary fix for https://github.com/npm/npm/issues/5905
            EnsureNpmGlobalDirectory();
            EnsureUserProfileDirectory();

            // Skip SSL Certificate Validate
            OperationClient.SkipSslValidationIfNeeded();

            // Make sure webpages:Enabled is true. Even though we set it in web.config, it could be overwritten by
            // an Azure AppSetting that's supposed to be for the site only but incidently affects Kudu as well.
            ConfigurationManager.AppSettings["webpages:Enabled"] = "true";

            // Kudu does not rely owin:appStartup.  This is to avoid Azure AppSetting if set.
            if (ConfigurationManager.AppSettings["owin:appStartup"] != null)
            {
                // Set the appSetting to null since we cannot use AppSettings.Remove(key) (ReadOnly exception!)
                ConfigurationManager.AppSettings["owin:appStartup"] = null;
            }

            RegisterRoutes(kernel, RouteTable.Routes);

            // Register the default hubs route: ~/signalr
            GlobalHost.DependencyResolver = new SignalRNinjectDependencyResolver(kernel);
            GlobalConfiguration.Configuration.Filters.Add(
                new TraceDeprecatedActionAttribute(
                    kernel.Get <IAnalytics>(),
                    kernel.Get <ITraceFactory>()));
            GlobalConfiguration.Configuration.Filters.Add(new EnsureRequestIdHandlerAttribute());
        }
示例#34
0
        internal static IEnumerable <GameObject> FindInstancesInScene(IEnumerable <GameObject> match, System.Func <GameObject, string> instanceNamingFunc)
        {
            //null checks
            if (match == null || instanceNamingFunc == null)
            {
                return(null);
            }

            IEnumerable <string> matches = match.Where(x => x != null).Select(y => instanceNamingFunc(y));

            return(UnityEngine.Object.FindObjectsOfType <GameObject>().Where(x => {
                return matches.Contains(x.name);
            }));
        }
示例#35
0
 internal static System.Collections.Generic.IDictionary <string, V> FromJson <V>(JsonObject json, System.Collections.Generic.Dictionary <string, V> container, System.Func <JsonObject, V> objectFactory, System.Collections.Generic.HashSet <string> excludes = null) => FromJson(json, (System.Collections.Generic.IDictionary <string, V>)container, objectFactory, excludes);
		/// <summary>
		/// A simple constructor that initializes the object with the given values.
		/// </summary>
		/// <param name="p_fncConfirmFoundInstallationPath">The delegate to call to confirm if a found path
		/// is correct.</param>
		public InstallationPathAutoDetector(System.Func<string, bool> p_fncConfirmFoundInstallationPath)
		{
			ConfirmFoundInstallationPath = p_fncConfirmFoundInstallationPath ?? (x => true);
		}
示例#37
0
        internal static System.Collections.Generic.IDictionary <string, V> FromJson <V>(JsonObject json, System.Collections.Generic.IDictionary <string, V> container, System.Func <JsonObject, V> objectFactory, System.Collections.Generic.HashSet <string> excludes = null)
        {
            if (null == json)
            {
                return(container);
            }

            foreach (var key in json.Keys)
            {
                if (true == excludes?.Contains(key))
                {
                    continue;
                }

                var value = json[key];
                try
                {
                    switch (value.Type)
                    {
                    case JsonType.Null:
                        // skip null values.
                        continue;

                    case JsonType.Array:
                    case JsonType.Boolean:
                    case JsonType.Date:
                    case JsonType.Binary:
                    case JsonType.Number:
                    case JsonType.String:
                        container.Add(key, (V)value.ToValue());
                        break;

                    case JsonType.Object:
                        if (objectFactory != null)
                        {
                            var v = objectFactory(value as JsonObject);
                            if (null != v)
                            {
                                container.Add(key, v);
                            }
                        }
                        break;
                    }
                }
                catch
                {
                }
            }
            return(container);
        }
示例#38
0
 /** <summary>
  *  To write out the value of an ASTExpr, invoke the evaluator in eval.g
  *  to walk the tree writing out the values.  For efficiency, don't
  *  compute a bunch of strings and then pack them together.  Write out directly.
  *  </summary>
  *
  *  <remarks>
  *  Compute separator and wrap expressions, save as strings so we don't
  *  recompute for each value in a multi-valued attribute or expression.
  *
  *  If they set anchor option, then inform the writer to push current
  *  char position.
  *  </remarks>
  */
 public override int Write( StringTemplate self, IStringTemplateWriter @out )
 {
     if ( _exprTree == null || self == null || @out == null )
     {
         return 0;
     }
     // handle options, anchor, wrap, separator...
     StringTemplateAST anchorAST = (StringTemplateAST)GetOption( "anchor" );
     if ( anchorAST != null )
     { // any non-empty expr means true; check presence
         @out.PushAnchorPoint();
     }
     @out.PushIndentation( Indentation );
     HandleExprOptions( self );
     //System.out.println("evaluating tree: "+exprTree.toStringList());
     #if COMPILE_EXPRESSIONS
     if ( EvaluateAction == null )
         EvaluateAction = GetEvaluator( this, AST );
     #else
     ActionEvaluator eval =
             new ActionEvaluator( self, this, @out, _exprTree );
     #endif
     int n = 0;
     try
     {
         // eval and write out tree
     #if COMPILE_EXPRESSIONS
         n = EvaluateAction( self, @out );
     #else
         n = eval.action();
     #endif
     }
     catch ( RecognitionException re )
     {
         self.Error( "can't evaluate tree: " + _exprTree.ToStringTree(), re );
     }
     @out.PopIndentation();
     if ( anchorAST != null )
     {
         @out.PopAnchorPoint();
     }
     return n;
 }
 void Push_System_Func_int_int(IntPtr L, System.Func <int, int> o)
 {
     ToLua.Push(L, o);
 }
 public static void NavigateTo(PhoneApplicationPage fromPage, TallySchedule template, PageActionType pageAction)
 {
     EditingItemGetter = () => template;
     fromPage.NavigateTo("/Pages/CustomizedTally/CustomizedTallyItemEditorPage.xaml?action={0}", new object[] { pageAction });
 }
示例#41
0
 public TResult Match <TResult>(Func <TResult> successAction, System.Func <string, TResult> errorAction) =>
 Error != null?errorAction(Error) : successAction(_value);
示例#42
0
 public LambdaHtmlSerializer(System.Func<Object, string, string> f)
 {
     this.f = f;
 }
示例#43
0
 internal static TimeValue.TimeBuilder <LocalTimeValue> Builder(System.Func <ZoneId> defaultZone)
 {
     return(new TimeBuilderAnonymousInnerClass(defaultZone));
 }
示例#44
0
 public LambdaCache(System.Func<string, long, JToken, object> set, System.Func<string, JToken> get)
 {
     this.set = set;
     this.get = get;
 }
 /// <summary>
 /// Looking for members without defined target attribute.
 /// </summary>
 /// <typeparam name="T">Attribute's type.</typeparam>
 /// <param name="source">Type the would by used as source of fields.</param>
 /// <param name="expression">Delegate that would be called to compare member by custom way.</param>
 /// <returns>Collection of found attributes.</returns>
 public static IEnumerable <MemberInfo> FindMembersWithoutAttribute <T>(IEnumerable <MemberInfo> source, System.Func <MemberInfo, bool> expression) where T : Attribute
 {
     return(source.Where(f => !Attribute.IsDefined(f, typeof(T)) && expression.Invoke(f)));
 }
示例#46
0
 public FunctionParameter(System.Func <T> f)
 //      :base((T)(object)0)
 {
     this.f = f;
     Update();
 }
示例#47
0
        private ListViewItem AddControl(string label, Bitmap bitmap, string imageKey, System.Func <PalasoImage, Control> makeControl)
        {
            _toolImages.Images.Add(bitmap);
            _toolImages.Images.SetKeyName(_toolImages.Images.Count - 1, imageKey);

            var item = new ListViewItem(label);

            item.ImageKey = imageKey;

            item.Tag = makeControl;
            this._toolListView.Items.Add(item);
            return(item);
        }
示例#48
0
		public CustomFunction (string aName, System.Func<double[], double> aDelegate, params IValue[] aValues)
		{
			m_Delegate = aDelegate;
			m_Params = aValues;
			m_Name = aName;
		}
示例#49
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BarcodeReader"/> class.
 /// </summary>
 /// <param name="reader">Sets the reader which should be used to find and decode the barcode.
 /// If null then MultiFormatReader is used</param>
 /// <param name="createLuminanceSource">Sets the function to create a luminance source object for a bitmap.
 /// If null, an exception is thrown when Decode is called</param>
 /// <param name="createBinarizer">Sets the function to create a binarizer object for a luminance source.
 /// If null then HybridBinarizer is used</param>
 public BarcodeReader(Reader reader,
                      System.Func <Image <Emgu.CV.Structure.Bgr, byte>, LuminanceSource> createLuminanceSource,
                      System.Func <LuminanceSource, Binarizer> createBinarizer)
     : base(reader, createLuminanceSource ?? defaultCreateLuminanceSource, createBinarizer)
 {
 }
示例#50
0
 /// <summary>
 /// ASYNC - Get historical trades for the exchange
 /// </summary>
 /// <param name="callback">Callback for each set of trades. Return false to stop getting trades immediately.</param>
 /// <param name="symbol">Symbol to get historical data for</param>
 /// <param name="sinceDateTime">Optional date time to start getting the historical data at, null for the most recent data</param>
 public async Task GetHistoricalTradesAsync(System.Func <IEnumerable <ExchangeTrade>, bool> callback, string symbol, DateTime?sinceDateTime = null)
 {
     await new SynchronizationContextRemover();
     await OnGetHistoricalTradesAsync(callback, symbol, sinceDateTime);
 }
示例#51
0
 protected virtual Task OnGetHistoricalTradesAsync(System.Func <IEnumerable <ExchangeTrade>, bool> callback, string symbol, DateTime?sinceDateTime = null) => throw new NotImplementedException();
示例#52
0
        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (_toolListView.SelectedItems.Count == 0)
                {
                    _previousSelectedIndex = -1;
                    return;
                }

                if (_previousSelectedIndex == _toolListView.SelectedIndices[0])
                {
                    return;
                }

                _previousSelectedIndex = _toolListView.SelectedIndices[0];

                ListViewItem selectedItem = _toolListView.SelectedItems[0];

                if (selectedItem.Tag == _currentControl)
                {
                    return;
                }

                bool haveImage = !(ImageInfo == null || ImageInfo.Image == null);

                //don't let them select crop (don't have a cheap way of 'disabling' a list item, sigh)

                if (!haveImage && selectedItem == _cropToolListItem)
                {
                    _cropToolListItem.Selected      = false;
                    _toolListView.Items[0].Selected = true;
                    return;
                }

                if (_currentControl != null)
                {
                    GetImageFromCurrentControl();

                    _panelForControls.Controls.Remove(_currentControl);
                    ((IImageToolboxControl)_currentControl).ImageChanged -= new EventHandler(imageToolboxControl_ImageChanged);
                    _currentControl.Dispose();
                }
                System.Func <PalasoImage, Control> fun =
                    (System.Func <PalasoImage, Control>)selectedItem.Tag;
                _currentControl = fun(ImageInfo);

                _currentControl.Dock = DockStyle.Fill;
                _panelForControls.Controls.Add(_currentControl);

                IImageToolboxControl imageToolboxControl = ((IImageToolboxControl)_currentControl);
                if (ImageInfo != null && ImageInfo.Image != null)
                {
                    imageToolboxControl.SetImage(ImageInfo);
                }
                imageToolboxControl.ImageChanged += new EventHandler(imageToolboxControl_ImageChanged);
                Refresh();
            }
            catch (Exception error)
            {
                ErrorReport.NotifyUserOfProblem(error, "Sorry, something went wrong with the ImageToolbox".Localize("ImageToolbox.GenericProblem"));
            }
        }
示例#53
0
 // 代入演算
 static public ExpressionToken OperateSubstition(ExpressionToken value1, ExpressionToken token, ExpressionToken value2, System.Func <string, object, bool> callbackSetValue)
 {
     value1.variable = CalcSubstition(value1.variable, token, value2.variable);
     //変数なので外部の代入処理
     if (value1.type == ExpressionToken.TokenType.Value)
     {
         if (!callbackSetValue(value1.name, value1.variable))
         {
             throw new Exception(LanguageErrorMsg.LocalizeTextFormat(Utage.ErrorMsg.ExpressionOperateSubstition, token.name, value1.variable));
         }
     }
     return(value1);
 }
		public IButtonComponent SetEnabledState(System.Func<bool> onState) {

			this.onState = onState;
			this.oldState = this.onState();
			this.onStateActive = true;

			return this;

		}
示例#55
0
    public HotPatcherEditor(ReadOnlyTargetRules Target) : base(Target)
    {
        PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
        bLegacyPublicIncludePaths = false;
        OptimizeCode = CodeOptimization.InShippingBuildsOnly;
        if (Target.Version.MajorVersion < 5 && Target.Version.MinorVersion <= 21)
        {
            bUseRTTI = true;
        }

        PublicIncludePaths.AddRange(new string[] { });
        PrivateIncludePaths.AddRange(new string[] {});

        PublicDependencyModuleNames.AddRange(
            new string[]
        {
            "UnrealEd",
            "UMG",
            "UMGEditor",
            "Core",
            "Json",
            "ContentBrowser",
            "SandboxFile",
            "JsonUtilities",
            "TargetPlatform",
            "DesktopPlatform",
            "Projects",
            "Settings",
            "HTTP",
            "RHI",
            "EngineSettings",
            "AssetRegistry",
            "PakFileUtilities",
            "HotPatcherRuntime",
            "BinariesPatchFeature",
            "HotPatcherCore"
            // ... add other public dependencies that you statically link with here ...
        }
            );

        PrivateDependencyModuleNames.AddRange(
            new string[]
        {
            "Core",
            "UnrealEd",
            "Projects",
            "DesktopPlatform",
            "InputCore",
            "EditorStyle",
            "LevelEditor",
            "CoreUObject",
            "Engine",
            "Slate",
            "SlateCore",
            "RenderCore"
            // ... add private dependencies that you statically link with here ...
        }
            );

        if (Target.Version.MajorVersion > 4 || Target.Version.MinorVersion > 23)
        {
            PublicDependencyModuleNames.AddRange(new string[] {
                "ToolMenus",
                "TraceLog"
            });
        }

        System.Func <string, bool, bool> AddPublicDefinitions = (string MacroName, bool bEnable) =>
        {
            PublicDefinitions.Add(string.Format("{0}={1}", MacroName, bEnable ? 1 : 0));
            return(true);
        };

        AddPublicDefinitions("ENABLE_COOK_ENGINE_MAP", false);
        AddPublicDefinitions("ENABLE_COOK_PLUGIN_MAP", false);
        BuildVersion Version;

        BuildVersion.TryRead(BuildVersion.GetDefaultFileName(), out Version);
        AddPublicDefinitions("WITH_EDITOR_SECTION", Version.MajorVersion > 4 || Version.MinorVersion > 24);
        // Game feature
        bool bEnableGameFeature = false;

        AddPublicDefinitions("ENGINE_GAME_FEATURE", bEnableGameFeature || (Target.Version.MajorVersion > 4 || Target.Version.MinorVersion > 26));

        System.Console.WriteLine("MajorVersion {0} MinorVersion: {1} PatchVersion {2}", Target.Version.MajorVersion, Target.Version.MinorVersion, Target.Version.PatchVersion);

        PublicDefinitions.AddRange(new string[]
        {
            "ENABLE_UPDATER_CHECK=1",
            "ENABLE_MULTI_COOKER=0",
            "TOOL_NAME=\"HotPatcher\"",
            "CURRENT_VERSION_ID=75",
            "CURRENT_PATCH_ID=2",
            "REMOTE_VERSION_FILE=\"https://imzlp.com/opensource/version.json\""
        });

        bool bEnablePackageContext = true;

        AddPublicDefinitions("WITH_PACKAGE_CONTEXT", (Version.MajorVersion > 4 || Version.MinorVersion > 23) && bEnablePackageContext);
        if (Version.MajorVersion > 4 || Version.MajorVersion > 26)
        {
            PublicDependencyModuleNames.AddRange(new string[]
            {
                "IoStoreUtilities",
                "UnrealEd"
            });
        }
    }
示例#56
0
        /** <summary>
         *  To write out the value of an ASTExpr, invoke the evaluator in eval.g
         *  to walk the tree writing out the values.  For efficiency, don't
         *  compute a bunch of strings and then pack them together.  Write out directly.
         *  </summary>
         *
         *  <remarks>
         *  Compute separator and wrap expressions, save as strings so we don't
         *  recompute for each value in a multi-valued attribute or expression.
         *
         *  If they set anchor option, then inform the writer to push current
         *  char position.
         *  </remarks>
         */
        public override int Write( StringTemplate self, IStringTemplateWriter @out )
        {
            if ( _exprTree == null || self == null || @out == null )
            {
                return 0;
            }
            // handle options, anchor, wrap, separator...
            StringTemplateAST anchorAST = (StringTemplateAST)GetOption( "anchor" );
            if ( anchorAST != null )
            { // any non-empty expr means true; check presence
                @out.PushAnchorPoint();
            }
            @out.PushIndentation( Indentation );
            HandleExprOptions( self );
            //System.out.println("evaluating tree: "+exprTree.toStringList());
            ActionEvaluator eval = null;
            #if COMPILE_EXPRESSIONS
            bool compile = self.Group != null && self.Group.EnableCompiledExpressions;
            bool cache = compile && self.Group.EnableCachedExpressions;
            System.Func<StringTemplate, IStringTemplateWriter, int> evaluator = EvaluateAction;
            if (compile)
            {
                if (!cache || EvaluateAction == null)
                {
                    // caching won't help here because AST is read only
                    EvaluatorCacheMisses++;
                    evaluator = GetEvaluator(this, AST);
                    if (cache)
                        EvaluateAction = evaluator;
                }
                else
                {
                    EvaluatorCacheHits++;
                }
            }
            else
            #endif
            {
                eval = new ActionEvaluator(self, this, @out, _exprTree);
            }

            int n = 0;
            try
            {
                // eval and write out tree
            #if COMPILE_EXPRESSIONS
                if (compile)
                {
                    n = evaluator(self, @out);
                }
                else
            #endif
                {
                    n = eval.action();
                }
            }
            catch ( RecognitionException re )
            {
                self.Error( "can't evaluate tree: " + _exprTree.ToStringTree(), re );
            }
            @out.PopIndentation();
            if ( anchorAST != null )
            {
                @out.PopAnchorPoint();
            }
            return n;
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e.NavigationMode != NavigationMode.Back)
            {
                System.Guid _id = this.GetNavigatingParameter("id", System.Guid.Empty).ToGuid();
                System.Threading.ThreadPool.QueueUserWorkItem(o =>
                {
                    AccountItem item = ViewModelLocator.AccountItemViewModel.AccountBookDataContext.AccountItems.FirstOrDefault<AccountItem>(p => p.Id == _id);
                    if (item != null)
                    {
                        if (item.Type == ItemType.Expense)
                        {
                            this.sameTypeItemListGetter = (id, date) => this.accountItemViewModel.FindGroup(this.accountItemViewModel.ExpenseItems, date)
                                .FirstOrDefault<AccountItem>(p => p.Id == id);
                        }
                        else
                        {
                            this.sameTypeItemListGetter = (id, date) =>
                              this.accountItemViewModel.FindGroup(this.accountItemViewModel.IncomeItems, date)
                              .FirstOrDefault<AccountItem>(p => p.Id == id);
                        }

                        this.Dispatcher.BeginInvoke(() =>
                        {
                            this.CurrentObject = item;
                            //  this.IncomeOrExpenseDetailsPivot.DataContext = this.CurrentObject;
                            this.MainPivot.DataContext = this.CurrentObject;
                            (this.MainPivot.Title as TextBlock).DataContext = this.CurrentObject;
                            this.InitializeMenuItemText();
                        });
                    }
                });
            }

            base.OnNavigatedTo(e);
        }
        private static T FilteredEnumPopupInternal <T>(T selectedValue, System.Func <T, bool> predicate, System.Func <int, string[], int> showPopup, System.Func <string, string> rename) where T : struct, System.IConvertible
        {
            if (!typeof(T).IsEnum)
            {
                throw new System.ArgumentException(typeof(T).Name + " is not an Enum", "T");
            }

            T[]      ary   = System.Enum.GetValues(typeof(T)).Cast <T>().Where(v => predicate(v)).ToArray();
            string[] names = ary.Select(e => System.Enum.GetName(typeof(T), e)).ToArray();

            int selectedIdx = 0;

            for (; selectedIdx < ary.Length; ++selectedIdx)
            {
                if (ary[selectedIdx].Equals(selectedValue))
                {
                    break;
                }
            }
            if (selectedIdx == ary.Length)
            {
                selectedIdx = 0;
            }

            if (ary.Length == 0)
            {
                throw new System.ArgumentException("Predicate filtered out all options", "predicate");
            }

            if (rename != null)
            {
                return(ary[showPopup(selectedIdx, names.Select(rename).ToArray())]);
            }
            else
            {
                return(ary[showPopup(selectedIdx, names)]);
            }
        }
示例#59
0
    public void RegisterType <Type>(System.Func <ByteString, object> des)
    {
        var typeName = typeof(Type).FullName;

        deserializeDict[typeName] = des;
    }
示例#60
-1
 static Parser()
 {
     CreateTrigger = delegate (DependencyObject target, string triggerText) {
         if (triggerText == null)
         {
             return ConventionManager.GetElementConvention(target.GetType()).CreateTrigger();
         }
         string str = triggerText.Replace("[", string.Empty).Replace("]", string.Empty).Replace("Event", string.Empty).Trim();
         return new System.Windows.Interactivity.EventTrigger { EventName = str };
     };
     InterpretMessageText = (target, text) => new ActionMessage { MethodName = Regex.Replace(text, "^Action", string.Empty).Trim() };
     CreateParameter = delegate (DependencyObject target, string parameterText) {
         Parameter actualParameter = new Parameter();
         if (parameterText.StartsWith("'") && parameterText.EndsWith("'"))
         {
             actualParameter.Value = parameterText.Substring(1, parameterText.Length - 2);
         }
         else if (MessageBinder.SpecialValues.ContainsKey(parameterText.ToLower()) || char.IsNumber(parameterText[0]))
         {
             actualParameter.Value = parameterText;
         }
         else if (target is FrameworkElement)
         {
             FrameworkElement fe = (FrameworkElement) target;
             string[] nameAndBindingMode = (from x in parameterText.Split(new char[] { ':' }) select x.Trim()).ToArray<string>();
             int index = nameAndBindingMode[0].IndexOf('.');
             View.ExecuteOnLoad(fe, (, ) => BindParameter(fe, actualParameter, (index == -1) ? nameAndBindingMode[0] : nameAndBindingMode[0].Substring(0, index), (index == -1) ? null : nameAndBindingMode[0].Substring(index + 1), (nameAndBindingMode.Length == 2) ? ((BindingMode) Enum.Parse(typeof(BindingMode), nameAndBindingMode[1], true)) : BindingMode.OneWay));
         }
         return actualParameter;
     };
 }