Example #1
0
        /// <summary>
        /// Parse the fields from a stream specification
        /// </summary>
        /// <param name="spec">Text of the stream specification in server format</param>
        /// <returns></returns>
        public bool Parse(String spec)
        {
            _baseForm = new FormBase();
            _baseForm.Parse(spec); // parse the values into the underlying dictionary
            GetSpecDefinition(_baseForm);

            Id          = ParseSingleString(_baseForm, "Stream");
            OwnerName   = ParseSingleString(_baseForm, "Owner");
            Name        = ParseSingleString(_baseForm, "Name");
            Description = ParseDescription(_baseForm);
            Ignored     = ParseView(_baseForm, "Ignored");
            Paths       = ParseView(_baseForm, "Paths");
            Remapped    = ParseView(_baseForm, "Remapped");
            View        = ParseView(_baseForm, "View");
            ChangeView  = ParseView(_baseForm, "ChangeView");
            Updated     = ParseDate(_baseForm, "Update");
            Accessed    = ParseDate(_baseForm, "Access");

            if (_baseForm.ContainsKey("Options"))
            {
                _options = _baseForm["Options"] as string;
                specDef.Remove("Options");
            }

            if (_baseForm.ContainsKey("Type"))
            {
                _type = _baseForm["Type"] as string;
                specDef.Remove("Type");
            }

            if (_baseForm.ContainsKey("ParentView"))
            {
                _parentView = (_baseForm["ParentView"].ToString() == "inherit") ? ParentView.Inherit : ParentView.NoInherit;
                //_parentView = _baseForm["ParentView"] as string;
                specDef.Remove("ParentView");
            }

            if (_baseForm.ContainsKey("Parent"))
            {
                string line = _baseForm["Parent"] as string;
                Parent = new DepotPath(line);
                specDef.Remove("Parent");
            }

            SetCustomFields();

            return(true);
        }
Example #2
0
        private void PopulateCommonFields(TaggedObject objectInfo)
        {
            if (objectInfo.ContainsKey("Stream"))
            {
                Id = objectInfo["Stream"];
                specDef.Remove("Stream");
            }

            if (objectInfo.ContainsKey("Owner"))
            {
                OwnerName = objectInfo["Owner"];
                specDef.Remove("Owner");
            }

            if (objectInfo.ContainsKey("Name"))
            {
                Name = objectInfo["Name"];
                specDef.Remove("Name");
            }

            if (objectInfo.ContainsKey("Parent"))
            {
                Parent = new DepotPath(objectInfo["Parent"]);
                specDef.Remove("Parent");
            }

            if (objectInfo.ContainsKey("baseParent"))
            {
                BaseParent = new DepotPath(objectInfo["baseParent"]);
                specDef.Remove("baseParent");
            }

            if (objectInfo.ContainsKey("Type"))
            {
                _type = (objectInfo["Type"]);
                specDef.Remove("Type");
            }

            if (objectInfo.ContainsKey("Description"))
            {
                Description = objectInfo["Description"];
                specDef.Remove("Description");
            }

            if (objectInfo.ContainsKey("desc"))
            {
                Description = objectInfo["desc"];
                specDef.Remove("desc");
            }

            if (objectInfo.ContainsKey("Options"))
            {
                String optionsStr = objectInfo["Options"];
                _options = optionsStr;
                specDef.Remove("Options");
            }

            if (objectInfo.ContainsKey("firmerThanParent"))
            {
                FirmerThanParent = objectInfo["firmerThanParent"];
                specDef.Remove("firmerThanParent");
            }

            if (objectInfo.ContainsKey("changeFlowsToParent"))
            {
                ChangeFlowsToParent = objectInfo["changeFlowsToParent"];
                specDef.Remove("changeFlowsToParent");
            }

            if (objectInfo.ContainsKey("changeFlowsFromParent"))
            {
                ChangeFlowsFromParent = objectInfo["changeFlowsFromParent"];
                specDef.Remove("changeFlowsFromParent");
            }

            if (objectInfo.ContainsKey("ParentView"))
            {
                _parentView = (objectInfo["ParentView"]);
                specDef.Remove("ParentView");
            }
        }
Example #3
0
        /// <summary>
        /// Read the fields from the tagged output of a 'stream' command
        /// </summary>
        /// <param name="objectInfo">Tagged output from the 'stream' command</param>
        public void FromStreamCmdTaggedOutput(TaggedObject objectInfo)
        {
            _baseForm = new FormBase();

            _baseForm.SetValues(objectInfo);

            if (objectInfo.ContainsKey("Stream"))
            {
                Id = objectInfo["Stream"];
            }

            if (objectInfo.ContainsKey("Update"))
            {
                DateTime v = DateTime.MinValue;
                DateTime.TryParse(objectInfo["Update"], out v);
                Updated = v;
            }

            if (objectInfo.ContainsKey("Access"))
            {
                DateTime v = DateTime.MinValue;
                DateTime.TryParse(objectInfo["Access"], out v);
                Accessed = v;
            }

            if (objectInfo.ContainsKey("Owner"))
            {
                OwnerName = objectInfo["Owner"];
            }

            if (objectInfo.ContainsKey("Name"))
            {
                Name = objectInfo["Name"];
            }

            if (objectInfo.ContainsKey("Parent"))
            {
                Parent = new DepotPath(objectInfo["Parent"]);
            }

            if (objectInfo.ContainsKey("baseParent"))
            {
                BaseParent = new DepotPath(objectInfo["baseParent"]);
            }

            if (objectInfo.ContainsKey("Type"))
            {
                _type = (objectInfo["Type"]);
            }

            if (objectInfo.ContainsKey("Description"))
            {
                Description = objectInfo["Description"];
            }

            if (objectInfo.ContainsKey("Options"))
            {
                String optionsStr = objectInfo["Options"];
                _options = optionsStr;
            }

            if (objectInfo.ContainsKey("firmerThanParent"))
            {
                FirmerThanParent = objectInfo["firmerThanParent"];
            }

            if (objectInfo.ContainsKey("changeFlowsToParent"))
            {
                ChangeFlowsToParent = objectInfo["changeFlowsToParent"];
            }

            if (objectInfo.ContainsKey("changeFlowsFromParent"))
            {
                ChangeFlowsFromParent = objectInfo["changeFlowsFromParent"];
            }

            int    idx = 0;
            string key = String.Format("Paths{0}", idx);

            if (objectInfo.ContainsKey(key))
            {
                Paths = new ViewMap();
                while (objectInfo.ContainsKey(key))
                {
                    Paths.Add(objectInfo[key]);
                    idx++;
                    key = String.Format("Paths{0}", idx);
                }
            }
            else
            {
                Paths = null;
            }

            idx = 0;
            key = String.Format("Remapped{0}", idx);
            if (objectInfo.ContainsKey(key))
            {
                Remapped = new ViewMap();
                PathSpec LeftPath  = new ClientPath(string.Empty);
                PathSpec RightPath = new ClientPath(string.Empty);
                MapEntry Remap     = new MapEntry(MapType.Include, LeftPath, RightPath);

                while (objectInfo.ContainsKey(key))
                {
                    string   l = (objectInfo[key]);
                    string[] p = l.Split(' ');
                    LeftPath  = new ClientPath(p[0]);
                    RightPath = new ClientPath(p[1]);
                    Remap     = new MapEntry(MapType.Include, LeftPath, RightPath);
                    Remapped.Add(Remap);
                    idx++;
                    key = String.Format("Remapped{0}", idx);
                }
            }
            else
            {
                Remapped = null;
            }

            idx = 0;
            key = String.Format("Ignored{0}", idx);
            if (objectInfo.ContainsKey(key))
            {
                Ignored = new ViewMap();
                PathSpec LeftPath  = new ClientPath(string.Empty);
                PathSpec RightPath = new ClientPath(string.Empty);
                MapEntry Ignore    = new MapEntry(MapType.Include, LeftPath, RightPath);

                while (objectInfo.ContainsKey(key))
                {
                    string   l = (objectInfo[key]);
                    string[] p = l.Split(' ');
                    LeftPath = new ClientPath(p[0]);
                    if (p.Length > 1)
                    {
                        RightPath = new ClientPath(p[1]);
                    }
                    Ignore = new MapEntry(MapType.Include, LeftPath, RightPath);
                    Ignored.Add(Ignore);
                    idx++;
                    key = String.Format("Ignored{0}", idx);
                }
            }
            else
            {
                Ignored = null;
            }

            idx = 0;
            key = String.Format("View{0}", idx);
            if (objectInfo.ContainsKey(key))
            {
                View = new ViewMap();
                while (objectInfo.ContainsKey(key))
                {
                    View.Add(objectInfo[key]);
                    idx++;
                    key = String.Format("View{0}", idx);
                }
            }
            else
            {
                View = null;
            }
        }
Example #4
0
        /// <summary>
        /// Parse the fields from a stream specification
        /// </summary>
        /// <param name="spec">Text of the stream specification in server format</param>
        /// <returns></returns>
        public bool Parse(String spec)
        {
            _baseForm = new FormBase();
            _baseForm.Parse(spec);             // parse the values into the underlying dictionary

            if (_baseForm.ContainsKey("Stream"))
            {
                Id = _baseForm["Stream"] as string;
            }

            if (_baseForm.ContainsKey("Update"))
            {
                DateTime d;
                if (DateTime.TryParse(_baseForm["Update"] as string, out d))
                {
                    Updated = d;
                }
            }

            if (_baseForm.ContainsKey("Access"))
            {
                DateTime d;
                if (DateTime.TryParse(_baseForm["Access"] as string, out d))
                {
                    Accessed = d;
                }
            }

            if (_baseForm.ContainsKey("Owner"))
            {
                OwnerName = _baseForm["Owner"] as string;
            }

            if (_baseForm.ContainsKey("Name"))
            {
                Name = _baseForm["Name"] as string;
            }

            if (_baseForm.ContainsKey("Parent"))
            {
                string line = _baseForm["Parent"] as string;
                Parent = new DepotPath(line);
            }

            if (_baseForm.ContainsKey("Type"))
            {
                _type = _baseForm["Type"] as string;
            }

            if (_baseForm.ContainsKey("Description"))
            {
                Description = _baseForm["Description"] as string;
            }

            if (_baseForm.ContainsKey("Options"))
            {
                _options = _baseForm["Options"] as string;
            }

            return(true);
        }
Example #5
0
        /// <summary>
        /// Read the fields from the tagged output of a 'streams' command
        /// </summary>
        /// <param name="objectInfo">Tagged output from the 'streams' command</param>
        /// <param name="offset">Date processing</param>
        /// <param name="dst_mismatch">DST for date</param>
        public void FromStreamsCmdTaggedOutput(TaggedObject objectInfo, string offset, bool dst_mismatch)
        {
            _baseForm = new FormBase();

            _baseForm.SetValues(objectInfo);

            if (objectInfo.ContainsKey("Stream"))
            {
                Id = objectInfo["Stream"];
            }

            if (objectInfo.ContainsKey("Update"))
            {
                DateTime UTC = FormBase.ConvertUnixTime(objectInfo["Update"]);
                DateTime GMT = new DateTime(UTC.Year, UTC.Month, UTC.Day, UTC.Hour, UTC.Minute, UTC.Second,
                                            DateTimeKind.Unspecified);
                Updated = FormBase.ConvertFromUTC(GMT, offset, dst_mismatch);
            }

            if (objectInfo.ContainsKey("Access"))
            {
                DateTime UTC = FormBase.ConvertUnixTime(objectInfo["Access"]);
                DateTime GMT = new DateTime(UTC.Year, UTC.Month, UTC.Day, UTC.Hour, UTC.Minute, UTC.Second,
                                            DateTimeKind.Unspecified);
                Accessed = FormBase.ConvertFromUTC(GMT, offset, dst_mismatch);
            }

            if (objectInfo.ContainsKey("Owner"))
            {
                OwnerName = objectInfo["Owner"];
            }

            if (objectInfo.ContainsKey("Name"))
            {
                Name = objectInfo["Name"];
            }

            if (objectInfo.ContainsKey("Parent"))
            {
                Parent = new DepotPath(objectInfo["Parent"]);
            }

            if (objectInfo.ContainsKey("baseParent"))
            {
                BaseParent = new DepotPath(objectInfo["baseParent"]);
            }

            if (objectInfo.ContainsKey("Type"))
            {
                _type = (objectInfo["Type"]);
            }

            if (objectInfo.ContainsKey("desc"))
            {
                Description = objectInfo["desc"];
            }

            if (objectInfo.ContainsKey("Options"))
            {
                String optionsStr = objectInfo["Options"];
                _options = optionsStr;
            }

            if (objectInfo.ContainsKey("firmerThanParent"))
            {
                FirmerThanParent = objectInfo["firmerThanParent"];
            }

            if (objectInfo.ContainsKey("changeFlowsToParent"))
            {
                ChangeFlowsToParent = objectInfo["changeFlowsToParent"];
            }

            if (objectInfo.ContainsKey("changeFlowsFromParent"))
            {
                ChangeFlowsFromParent = objectInfo["changeFlowsFromParent"];
            }

            int    idx = 0;
            string key = String.Format("Paths{0}", idx);

            if (objectInfo.ContainsKey(key))
            {
                ViewMap Paths                  = new ViewMap();
                StringEnum <MapType> map       = null;
                PathSpec             LeftPath  = null;
                PathSpec             RightPath = null;
                MapEntry             Path      = new MapEntry(map, LeftPath, RightPath);

                while (objectInfo.ContainsKey(key))
                {
                    string   l = (objectInfo[key]);
                    string[] p = l.Split(' ');
                    map       = p[0];
                    LeftPath  = new DepotPath(p[1]);
                    RightPath = new DepotPath(p[2]);
                    Path      = new MapEntry(map, LeftPath, RightPath);
                    Paths.Add(Path);
                    idx++;
                    key = String.Format("Paths{0}", idx);
                }
            }

            idx = 0;
            key = String.Format("Remapped{0}", idx);
            if (objectInfo.ContainsKey(key))
            {
                ViewMap  Remapped  = new ViewMap();
                PathSpec LeftPath  = null;
                PathSpec RightPath = null;
                MapEntry Remap     = new MapEntry(MapType.Include, LeftPath, RightPath);

                while (objectInfo.ContainsKey(key))
                {
                    string   l = (objectInfo[key]);
                    string[] p = l.Split(' ');
                    LeftPath  = new DepotPath(p[0]);
                    RightPath = new DepotPath(p[1]);
                    Remap     = new MapEntry(MapType.Include, LeftPath, RightPath);
                    Remapped.Add(Remap);
                    idx++;
                    key = String.Format("Remapped{0}", idx);
                }
            }

            idx = 0;
            key = String.Format("Ignored{0}", idx);
            if (objectInfo.ContainsKey(key))
            {
                List <FileSpec> Ignored = new List <FileSpec>();
                FileSpec        ignore  = new FileSpec(new DepotPath(string.Empty), null);

                while (objectInfo.ContainsKey(key))
                {
                    string i = (objectInfo[key]);
                    ignore = new FileSpec(new DepotPath(i), null);
                    Ignored.Add(ignore);
                    idx++;
                    key = String.Format("Remapped{0}", idx);
                }
            }
            else
            {
                Ignored = null;
            }
        }