Пример #1
0
        public string DehydrateValue(object obj, IGraph uow)
        {
            Condition.Requires(obj).IsNotNull();

            T      tObj      = (T)obj;
            IGraph actualUow = null;

            //if we don't have a uow we use the default one
            if (uow == null)
            {
                actualUow = Graph.NewDefault();
            }

            List <string> lines = new List <string>();

            foreach (var each in Maps)
            {
                MemberMapping <T> eachMap = (MemberMapping <T>)each;
                var val = eachMap.Getter(tObj);

                //note we inject a null check decoration below
                var mgr       = actualUow.ChainOfResponsibility.GetValueManagerById(each.ValueManagerId).DecorateWithNullCheck();
                var stringVal = mgr.DehydrateValue(val, actualUow);
                lines.Add(stringVal);
            }
            return(LengthEncoder.LengthEncodeList(lines.ToArray()));
        }
Пример #2
0
        string IStringable.GetValue()
        {
            //split into: serializerid,instancetype name,serialized data
            var rv = LengthEncoder.LengthEncodeList(this.Id, this.InstanceType.AssemblyQualifiedName, this.SerializedData);

            return(rv);
        }
Пример #3
0
        public string DehydrateValue(object obj, IGraph uow)
        {
            Condition.Requires(obj).IsNotNull();
            var name = obj.GetType().Name;
            var val  = obj.ToString();

            return(LengthEncoder.LengthEncodeList(name, val));
        }
Пример #4
0
        public string DehydrateValue(object obj, IGraph uow)
        {
            Condition.Requires(obj).IsNotNull();
            var name = obj.GetType().AssemblyQualifiedName;
            var data = BinarySerializationUtil.Serialize(obj);

            return(LengthEncoder.LengthEncodeList(name, data));
        }
Пример #5
0
        public string GetValue()
        {
            var storeText = this.NodeStore.DehydrateNodeStore();

            var    managerText = this.ChainOfResponsibility.GetValue();
            string rv          = LengthEncoder.LengthEncodeList(managerText, storeText);

            return(rv);
        }
Пример #6
0
        public string DehydrateValue(object obj, IGraph uow)
        {
            Condition.Requires(obj).IsNotNull();
            var         name = obj.GetType().AssemblyQualifiedName;
            IStringable s    = obj as IStringable;
            var         data = s.GetValue();

            return(LengthEncoder.LengthEncodeList(name, data));
        }
Пример #7
0
        public string DehydrateValue(object obj, IGraph uow)
        {
            var typeName            = obj.GetType().AssemblyQualifiedName;
            IHasHydrationMap hasMap = obj as IHasHydrationMap;
            var map = hasMap.GetHydrationMap();

            Condition.Requires(map).IsNotNull();
            var data = map.DehydrateValue(obj, uow);

            return(LengthEncoder.LengthEncodeList(typeName, data));
        }
Пример #8
0
        public override string ToString()
        {
            List <string> data = new List <string>()
            {
                this.Id.ToString(),
                this.DateCreated.ToString(),
                this.GUID.ToString(),
                this.MachineName,
                this.IPAddress.ToString()
            };

            return(LengthEncoder.LengthEncodeList(data.ToArray()));
        }
Пример #9
0
        /// <summary>
        /// serializes the list of nodes by dehydrating each node and adding to a delimited string
        /// </summary>
        /// <param name="nodes"></param>
        /// <returns></returns>
        public static string DehydrateNodeList(List <GraphNode> nodes)
        {
            if (nodes == null)
            {
                return(null);
            }

            List <string> lines = new List <string>();

            nodes.WithEach(node =>
            {
                lines.Add(node.GetValue());
            });
            var rv = LengthEncoder.LengthEncodeList(lines.ToArray());

            return(rv);
        }
Пример #10
0
        public static string SerializeStore(IGetAllableStore store, ValueManagerChainOfResponsibility managerSet)
        {
            if (store == null)
            {
                return(null);
            }

            var           all   = store.GetAll();
            List <string> lines = new List <string>();

            all.WithEach(each =>
            {
                var line = SerializeItem(each, managerSet);
                lines.Add(line);
            });

            var raw = LengthEncoder.LengthEncodeList(lines.ToArray());

            return(raw);
        }
        public string DehydrateValue(object obj, IGraph uow)
        {
            if (!(obj is IManagedHydrateable))
            {
                return(null);
            }

            //do we have the indicated value manager?  if not, we'll skip and let the chain decide
            IManagedHydrateable hyd = obj as IManagedHydrateable;
            var mgrId = hyd.GetValueManagerId();
            var mgr   = uow.ChainOfResponsibility.GetValueManagerById(mgrId);

            if (mgr == null)
            {
                return(null);
            }

            var val = mgr.DehydrateValue(obj, uow);

            return(LengthEncoder.LengthEncodeList(mgrId, val));
        }
Пример #12
0
        public string DehydrateValue(object obj, IGraph uow)
        {
            List <string> ignoreMgrIds = new List <string>();

            if (this.ManagerIdsToIgnore != null)
            {
                ignoreMgrIds.AddRange(this.ManagerIdsToIgnore);
            }
            if (!ignoreMgrIds.Contains(UndeclaredValueManager.ID))
            {
                ignoreMgrIds.Add(UndeclaredValueManager.ID);
            }

            var mgr = uow.ChainOfResponsibility.FindHandlingValueManager(obj, uow, ignoreMgrIds.ToArray());

            if (mgr == null)
            {
                return(null);
            }

            var data = mgr.DehydrateValue(obj, uow);

            return(LengthEncoder.LengthEncodeList(mgr.Id, data));
        }
Пример #13
0
        public string GetValue()
        {
            var rv = LengthEncoder.LengthEncodeList(this.TraversalIndex.ToString(), this.ValueManagerId, this.Id, this.Context);

            return(rv);
        }
Пример #14
0
        public string GetValue()
        {
            var ids = this.ValueManagers.Select((x) => { return(x.Id); });

            return(LengthEncoder.LengthEncodeList(ids.ToArray()));
        }