Exemplo n.º 1
0
        private static object get(thing.Parts.Memory m, thing.Parts.Memory.MemoryComponents Part)
        {
            switch (Part)
            {
            case thing.Parts.Memory.MemoryComponents.KEY:
                return(m.Key);

            case thing.Parts.Memory.MemoryComponents.NAME:
                return(m.Name);

            case thing.Parts.Memory.MemoryComponents.VALUE:
                return(m.Value);

            default:
                return(null);
            }
        }
Exemplo n.º 2
0
        private static bool compare(thing.Parts.Memory a, thing.Parts.Memory b, thing.Parts.Memory.MemoryComponents Part)
        {
            switch (Part)
            {
            case thing.Parts.Memory.MemoryComponents.KEY:
                if (a.Key == b.Key)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }

            case thing.Parts.Memory.MemoryComponents.NAME:
                if (a.Name == b.Name)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }

            case thing.Parts.Memory.MemoryComponents.VALUE:
                if (a.Value == b.Value)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }

            default:
                return(false);
            }
        }
Exemplo n.º 3
0
        private static object tryGetCommonField(ref Memories MemoryHaystack, String KeyS, KeyWord KeyK, thing.Parts.Memory.MemoryComponents InPart, thing.Parts.Memory.MemoryComponents OutPart)
        {
            thing.Parts.Memory MemoryNeedle = new thing.Parts.Memory(KeyS, KeyK, String.Empty);
            foreach (thing.Parts.Memory Memory in MemoryHaystack)
            {
                switch (InPart)
                {
                case thing.Parts.Memory.MemoryComponents.KEY:
                    if (!Object.Equals(null, KeyK))
                    {
                        if (KeyK != KeyWord.NIL)
                        {
                            if (compare(Memory, MemoryNeedle, InPart))
                            {
                                return(get(Memory, OutPart));
                            }
                        }
                    }
                    if (!Object.Equals(null, KeyS))
                    {
                        if (KeyS != String.Empty)
                        {
                            if (compare(Memory, MemoryNeedle, InPart))
                            {
                                return(get(Memory, OutPart));
                            }
                        }
                    }
                    break;

                case thing.Parts.Memory.MemoryComponents.NAME:
                    if (!Object.Equals(null, KeyK))
                    {
                        if (KeyK != KeyWord.NIL)
                        {
                            if (compare(Memory, MemoryNeedle, InPart))
                            {
                                return(get(Memory, OutPart));
                            }
                        }
                    }
                    if (!Object.Equals(null, KeyS))
                    {
                        if (KeyS != String.Empty)
                        {
                            if (compare(Memory, MemoryNeedle, InPart))
                            {
                                return(get(Memory, OutPart));
                            }
                        }
                    }
                    break;
                }
            }
            return(null);
        }
Exemplo n.º 4
0
        public static bool tryGetCommonField(ref Memories Memories, String KeyS, KeyWord KeyK, System.Type OutValueType, thing.Parts.Memory.MemoryComponents InPart, thing.Parts.Memory.MemoryComponents OutPart, ref object outVar)
        {
            try
            {
                //lock (Memories)
                //{
                String TYPE_STRING    = typeof(System.String).ToString();
                String TYPE_INT       = typeof(System.Int32).ToString();
                String TYPE_BOOL      = typeof(System.Boolean).ToString();
                String TYPE_KEYWORD   = typeof(thing.KeyWord).ToString();
                String OUT_VALUE_TYPE = OutValueType.ToString();

                Object o = null;
                // lock (Memories)
                // {
                o = tryGetCommonField(ref Memories, KeyS, KeyK, InPart, OutPart);
                // }

                string s = String.Empty;
                if (object.Equals(null, o))
                {
                    return(false);
                }
                if (OUT_VALUE_TYPE == TYPE_STRING)
                {
                    s      = (String)o;
                    outVar = s;
                    return(true);
                }
                else if (OUT_VALUE_TYPE == TYPE_BOOL)
                {
                    s = (String)o;
                    if (s != String.Empty)
                    {
                        outVar = Boolean.Parse(s);
                        return(true);
                    }
                    else
                    {
                        outVar = false;
                        return(false);
                    }
                }
                else if (OUT_VALUE_TYPE == TYPE_INT)
                {
                    s = (String)o;
                    if (s != String.Empty)
                    {
                        outVar = System.Int32.Parse(s);
                        return(true);
                    }
                    else
                    {
                        outVar = 0;
                        return(false);
                    }
                }
                else if (OUT_VALUE_TYPE == TYPE_KEYWORD)
                {
                    outVar = (thing.KeyWord)o;
                    return(true);
                }
                else
                {
                    outVar = null;
                    return(false);
                }
                //}
            }
            catch //(Exception e)
            {
                // _Log(e.ToString());
                return(false);
            }
        }