/// <summary>Initializes the extension</summary>
        /// <param name="parameters">Initialization parameters: Thic class expects following parameters:
        /// <list type="table"><listheader><term>Parameter</term><description>Description</description></listheader>
        /// <item><term><c>PropertyName</c></term><description>Name of property to be altered. Required.</description></item>
        /// <item><term><c>TypeName</c></term><description>Name of type property <c>PropertyName</c> is property of. Required.</description></item>
        /// <item><term><c>Kind</c></term><description>Kind of date time value. Either <c>Date</c> (date only) or <c>DateTime</c> (date including time part). Optional. Default <c>DateTime</c>.</description></item>
        /// <item><term><c>Empty</c></term><description>How to deal with empty values. <c>Empty</c> - Empty string, <c>Null</c> - null. Optional. Not specified - null values are not treated in a a special way.</description></item>
        /// </list></param>
        /// <exception cref="KeyNotFoundException">A required parameter is not present in the <paramref name="parameters"/> dictionary.</exception>
        /// <exception cref="ArgumentException">
        /// Key <c>Kind</c> is present in <paramref name="parameters"/> bot value is neither <c>Date</c> nor <c>DateTime</c>. -or-
        /// Key <c>Empty</c> is present in <paramref name="parameters"/> bot value is neither <c>Empty</c> nor <c>Null</c>.
        /// </exception>
        public void Initialize(System.Collections.Generic.IDictionary <string, string> parameters)
        {
            propertyName = parameters["PropertyName"];
            typeName     = parameters["TypeName"];
            if (parameters.ContainsKey("Kind"))
            {
                switch (parameters["Kind"])
                {
                case "Date": dateOnly = true; break;

                case "DateTime": dateOnly = false; break;

                default: throw new ArgumentException(string.Format(Resources.ex_UknnownDateSerializationKind));
                }
            }
            if (parameters.ContainsKey("Empty"))
            {
                switch (parameters["Empty"])
                {
                case "Empty": empty = true; break;

                case "Null": empty = false; break;

                default: throw new ArgumentException(string.Format(Resources.ex_UknnownNullSerializationOption));
                }
            }
        }
Beispiel #2
0
        public Type GetDerivedTypeFor(Type derivedSourceType)
        {
            if (!_includedDerivedTypes.ContainsKey(derivedSourceType))
            {
                return(DestinationType);
            }

            return(_includedDerivedTypes[derivedSourceType]);
        }
        private static void InsertLoop(S2Loop newLoop, S2Loop parent, System.Collections.Generic.IDictionary <NullObject <S2Loop>, List <S2Loop> > loopMap)
        {
            List <S2Loop> children = null;

            if (loopMap.ContainsKey(parent))
            {
                children = loopMap[parent];
            }

            if (children == null)
            {
                children        = new List <S2Loop>();
                loopMap[parent] = children;
            }

            foreach (var child in children)
            {
                if (child.ContainsNested(newLoop))
                {
                    InsertLoop(newLoop, child, loopMap);
                    return;
                }
            }

            // No loop may contain the complement of another loop. (Handling this case
            // is significantly more complicated.)
            // assert (parent == null || !newLoop.containsNested(parent));

            // Some of the children of the parent loop may now be children of
            // the new loop.
            List <S2Loop> newChildren = null;

            if (loopMap.ContainsKey(newLoop))
            {
                newChildren = loopMap[newLoop];
            }
            for (var i = 0; i < children.Count;)
            {
                var child = children[i];
                if (newLoop.ContainsNested(child))
                {
                    if (newChildren == null)
                    {
                        newChildren      = new List <S2Loop>();
                        loopMap[newLoop] = newChildren;
                    }
                    newChildren.Add(child);
                    children.RemoveAt(i);
                }
                else
                {
                    ++i;
                }
            }
            children.Add(newLoop);
        }
Beispiel #4
0
 /// <summary>Initializes the extension</summary>
 /// <param name="parameters">Initialization parameters: Expects one optional parameter <c>Type</c>. If specified processes only properties of type with given name.</param>
 public void Initialize(System.Collections.Generic.IDictionary <string, string> parameters)
 {
     if (parameters.ContainsKey("Type"))
     {
         typeName = parameters["Type"];
     }
 }
        public void initialize()
        {
            //kodlama karsiliklari dosyasini oku
            StreamReader reader = new KaynakYukleyici().getReader("kaynaklar/tr/bilgi/kodlama-donusum.txt");
            String       s;

            while ((s = reader.ReadLine()) != null)
            {
                // bos ve # isaretli satirlari atla
                if (s.Length == 0 || s[0] == '#')
                {
                    continue;
                }
                s = toNative(s);
                Char c = s[0];

                //satirdan turkce karaktere karsilik duzen kod cekiliyor. ve bu kod map'a yerletiriliyor
                String kod = s.Substring(2);
                if (donusumler.ContainsKey(c))
                {
                    IList a = donusumler[c];
                    a.Add(kod);
                }
                else
                {
                    IList yeni = new ArrayList();
                    yeni.Add(kod);
                    donusumler.Add(c, yeni);
                }
            }
        }
        /** Moves a set of vertices from old to new positions. */

        private void MoveVertices(System.Collections.Generic.IDictionary <S2Point, S2Point> mergeMap)
        {
            if (mergeMap.Count == 0)
            {
                return;
            }

            // We need to copy the set of edges affected by the move, since
            // this.edges_could be reallocated when we start modifying it.
            var edgesCopy = new List <S2Edge>();

            foreach (var edge in _edges)
            {
                var v0   = edge.Key;
                var vset = edge.Value;
                foreach (var v1 in vset)
                {
                    if (mergeMap.ContainsKey(v0) || mergeMap.ContainsKey(v1))
                    {
                        // We only need to modify one copy of each undirected edge.
                        if (!_options.UndirectedEdges || v0 < v1)
                        {
                            edgesCopy.Add(new S2Edge(v0, v1));
                        }
                    }
                }
            }

            // Now erase all the old edges, and add all the new edges. This will
            // automatically take care of any XORing that needs to be done, because
            // EraseEdge also erases the sibiling of undirected edges.
            for (var i = 0; i < edgesCopy.Count; ++i)
            {
                var v0 = edgesCopy[i].Start;
                var v1 = edgesCopy[i].End;
                EraseEdge(v0, v1);
                if (mergeMap.ContainsKey(v0))
                {
                    v0 = mergeMap[v0];
                }
                if (mergeMap.ContainsKey(v1))
                {
                    v1 = mergeMap[v1];
                }
                AddEdge(v0, v1);
            }
        }
 public void Restore(System.Collections.Generic.IDictionary <string, object> state)
 {
     if (state.ContainsKey("BlogPageComments"))
     {
         _comments = state["BlogPageComments"] as ObservableCollection <Message>;
         result    = state["BlogPageResult"] as PagedResultOfTrainingDayCommentDTO5oAtqRlh;
     }
     setCommentsStatus();
 }
 public static T Get <T>(this System.Collections.Generic.IDictionary <string, object> dictionary, string key, T defaultValue)
 {
     if (dictionary.ContainsKey(key))
     {
         object value;
         dictionary.TryGetValue(key, out value);
         return(ValueUtility.ChangeType <T>(value, defaultValue));
     }
     return(defaultValue);
 }
        public static void Register <TFactoryInterface, TFactoryClass>() where TFactoryClass : TFactoryInterface, new()
        {
            var factoryType = typeof(TFactoryInterface);

            if (!_factories.ContainsKey(factoryType))
            {
                throw new ArgumentOutOfRangeException(nameof(TFactoryInterface), "Unknown factory type : " + factoryType);
            }
            _factories[factoryType] = () => new TFactoryClass();
        }
 public static void AddAllIfNotContains(System.Collections.Generic.IDictionary <string, string> hashtable, System.Collections.Generic.ICollection <string> items)
 {
     foreach (string s in items)
     {
         if (hashtable.ContainsKey(s) == false)
         {
             hashtable.Add(s, s);
         }
     }
 }
Beispiel #11
0
 internal static void AddErrors(System.Collections.Generic.IDictionary <string, HashSet <string> > errors, string propertyName, HashSet <string> validationResults)
 {
     if (errors.ContainsKey(propertyName))
     {
         errors[propertyName] = validationResults;
     }
     else
     {
         errors.Add(propertyName, validationResults);
     }
 }
 public void Restore(System.Collections.Generic.IDictionary <string, object> state)
 {
     if (state.ContainsKey("PageComments"))
     {
         Comments = state["PageComments"] as ObservableCollection <VoteViewModel>;
         result   = state["PageResult"] as PagedResultOfCommentEntryDTO5oAtqRlh;
         loaded   = (bool)state["Loaded"];
         entry    = (IRatingable)state["Entry"];
         updateNoRatingsLabel();
     }
     //setCommentsStatus();
 }
Beispiel #13
0
        private object DeserializeInternal(int depth)
        {
            if (++depth > this._depthLimit)
            {
                throw new System.ArgumentException(this._s.GetDebugString("RecursionLimit exceeded."));
            }
            char?  nextNonEmptyChar = this._s.GetNextNonEmptyChar();
            char?  c = nextNonEmptyChar;
            object result;

            if (!(c.HasValue ? new int?((int)c.GetValueOrDefault()) : null).HasValue)
            {
                result = null;
            }
            else
            {
                this._s.MovePrev();
                if (this.IsNextElementDateTime())
                {
                    result = this.DeserializeStringIntoDateTime();
                }
                else if (JavaScriptObjectDeserializer.IsNextElementObject(nextNonEmptyChar))
                {
                    System.Collections.Generic.IDictionary <string, object> dictionary = this.DeserializeDictionary(depth);
                    if (dictionary.ContainsKey("__type"))
                    {
                        result = ObjectConverter.ConvertObjectToType(dictionary, null, this._serializer);
                    }
                    else
                    {
                        result = dictionary;
                    }
                }
                else if (JavaScriptObjectDeserializer.IsNextElementArray(nextNonEmptyChar))
                {
                    result = this.DeserializeList(depth);
                }
                else if (JavaScriptObjectDeserializer.IsNextElementString(nextNonEmptyChar))
                {
                    result = this.DeserializeString();
                }
                else
                {
                    result = this.DeserializePrimitiveObject();
                }
            }
            return(result);
        }
            protected override Expression VisitMember(MemberExpression node)
            {
                if (!node.Member.DeclaringType.Name.Contains("<>"))
                {
                    return(base.VisitMember(node));
                }

                if (!_paramValues.ContainsKey(node.Member.Name))
                {
                    return(base.VisitMember(node));
                }

                return(Expression.Convert(
                           Expression.Constant(_paramValues[node.Member.Name]),
                           node.Member.GetMemberType()));
            }
Beispiel #15
0
        internal static IEnumerable GetErrors(System.Collections.Generic.IDictionary <string, HashSet <string> > errors, string propertyName)
        {
            if (propertyName == null)
            {
                yield break;
            }

            if (!errors.ContainsKey(propertyName))
            {
                yield break;
            }

            foreach (var result in errors[propertyName])
            {
                yield return(result);
            }
        }
Beispiel #16
0
        protected override void OnPageEncountered(Uri url, System.Collections.Generic.IDictionary <string, string> query, System.Collections.Generic.IDictionary <string, string> fragment)
        {
            // Remove state from dictionaries.
            // We are ignoring request state forgery status
            // as we're hitting an ASP.NET service which forwards
            // to a third-party OAuth service itself
            if (query.ContainsKey("state"))
            {
                query.Remove("state");
            }

            if (fragment.ContainsKey("state"))
            {
                fragment.Remove("state");
            }

            base.OnPageEncountered(url, query, fragment);
        }
Beispiel #17
0
 public static string GetFormatValueString(this System.Collections.Generic.IDictionary <string, object> dictionary, string formatString, string captureRule)
 {
     System.Collections.Generic.IDictionary <string, string> dictionary2 = FormatParser.CaptureFormatKey(formatString, captureRule);
     if (dictionary2.Count > 0)
     {
         foreach (System.Collections.Generic.KeyValuePair <string, string> current in dictionary2)
         {
             if (dictionary.ContainsKey(current.Key))
             {
                 formatString = formatString.Replace(current.Value, Utils.GetString(dictionary[current.Key]));
             }
         }
     }
     else
     {
         formatString = Utils.GetString(dictionary[formatString.ToUpper()]);
     }
     return(formatString);
 }
        private void InitLoop(S2Loop loop, int depth, System.Collections.Generic.IDictionary <NullObject <S2Loop>, List <S2Loop> > loopMap)
        {
            if (loop != null)
            {
                loop.Depth = depth;
                _loops.Add(loop);
            }
            List <S2Loop> children = null;

            if (loopMap.ContainsKey(loop))
            {
                children = loopMap[loop];
            }
            if (children != null)
            {
                foreach (var child in children)
                {
                    InitLoop(child, depth + 1, loopMap);
                }
            }
        }
Beispiel #19
0
        private float getDeviceLastPdValue(string ip, System.Collections.Generic.IDictionary <string, float> lastDevicePdValue)
        {
            float result;

            try
            {
                if (lastDevicePdValue == null || lastDevicePdValue.Count < 1 || !lastDevicePdValue.ContainsKey(ip))
                {
                    result = 0f;
                }
                else
                {
                    result = System.Convert.ToSingle(lastDevicePdValue[ip].ToString("0.00"));
                }
            }
            catch (System.Exception)
            {
                result = 0f;
            }
            return(result);
        }
        protected override void ActivateView(string viewName, System.Collections.Generic.IDictionary <string, object> viewParameters)
        {
            StartPerformanceTimer();

            string   view       = "";
            DateTime?period     = null;
            Employee employee   = null;
            DateTime?searchDate = null;

            object value = null;

            if (viewParameters.TryGetValue("New", out value))
            {
                IsNew = (bool)value;
            }

            if (viewParameters.ContainsKey("NewProfitCenter"))
            {
                NewOrganizationCreated = (Organization)viewParameters["NewProfitCenter"];
            }

            employee = (Employee)viewParameters["Employee"];

            // Check if any specific view should be set as active
            if (viewParameters.ContainsKey("SelectedView"))
            {
                view = viewParameters["SelectedView"].ToString();
            }
            // Check if a period should be loaded
            if (viewParameters.ContainsKey("Period") && viewParameters["Period"].ToString().Length > 0)
            {
                DateTime result;
                DateTime.TryParse(viewParameters["Period"].ToString(), out result);
                period = result;
            }

            if (viewParameters.ContainsKey("SearchDate") && viewParameters["SearchDate"] != null && viewParameters["SearchDate"].ToString().Length > 0)
            {
                DateTime result;
                DateTime.TryParse(viewParameters["SearchDate"].ToString(), out result);
                searchDate = result;
            }

            ReportControl = new ReportControlViewModel();
            if (employee != null)
            {
                ReportControl.CurrentEmployeeNumber = employee.EmployeeNumberStr;
                ReportControl.CurrentEmployeeId     = employee.EmployeeId;
            }
            ReportControl.LoadReportsForView((int)ReportViews.Employee, ReportService);
            RaisePropertyChanged(() => ReportControl);

            // Sanity check!
            if (employee == null)
            {
                return;
            }

            // Check if new or existing employee
            if (employee.EmployeeId > 0)
            {
                // Load employee from server
                LoadEmployee(employee.EmployeeId, searchDate, () => SetActiveView(view, period));
            }
            else
            {
                // New employee
                Employee = employee;
                LoadChildViewmodels();
                // Select first view
                if (_childVM != null && _childVM.Count > 0)
                {
                    SelectedView = _childVM[0];
                }
            }
        }
Beispiel #21
0
 public static System.Collections.Generic.IDictionary <string, string> Merger(this System.Collections.Generic.IDictionary <string, string> dictionary, object o, bool nullValueAsKey, ECase keyECase, bool includeInheritedProperty)
 {
     if (o != null)
     {
         if (o is System.Collections.Generic.IDictionary <string, string> )
         {
             System.Collections.Generic.IDictionary <string, string> dictionary2 = o as System.Collections.Generic.IDictionary <string, string>;
             foreach (string text in dictionary2.Keys)
             {
                 if (dictionary.ContainsKey(text.ToUpper()))
                 {
                     dictionary[text.ToUpper()] = dictionary2[text];
                 }
                 else
                 {
                     dictionary.Add(text.ToUpper(), dictionary2[text]);
                 }
             }
         }
         else
         {
             System.Reflection.PropertyInfo[] array  = includeInheritedProperty ? o.GetType().GetProperties(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public) : o.GetType().GetProperties(System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);
             System.Reflection.PropertyInfo[] array2 = array;
             for (int i = 0; i < array2.Length; i++)
             {
                 System.Reflection.PropertyInfo propertyInfo = array2[i];
                 string text = propertyInfo.Name;
                 if (keyECase == ECase.UPPER)
                 {
                     text = text.ToUpper();
                 }
                 else
                 {
                     if (keyECase == ECase.LOWER)
                     {
                         text = text.ToLower();
                     }
                 }
                 object value = propertyInfo.GetValue(o, null);
                 if (value != null)
                 {
                     if (!dictionary.ContainsKey(text))
                     {
                         dictionary.Add(text, value.ToString());
                     }
                     else
                     {
                         dictionary[text] = value.ToString();
                     }
                 }
                 else
                 {
                     if (nullValueAsKey)
                     {
                         if (!dictionary.ContainsKey(text))
                         {
                             dictionary.Add(text, null);
                         }
                         else
                         {
                             dictionary[text] = null;
                         }
                     }
                 }
             }
         }
     }
     return(dictionary);
 }