Exemplo n.º 1
0
        private void appendProcedureRelations(Dlineage dlineage, Element dlineageRelation)
        {
            targetProcedure[] targetProcedures = dlineage.Procedures.Item1.targetProcedures;
            if (targetProcedures != null && targetProcedures.Length > 0)
            {
                for (int z = 0; z < targetProcedures.Length; z++)
                {
                    targetProcedure target = targetProcedures[z];
                    if (target.sourceProcedures != null)
                    {
                        for (int j = 0; j < target.sourceProcedures.Length; j++)
                        {
                            sourceProcedure source = target.sourceProcedures[j];

                            Element relationNode = new Element("relation");

                            Element sourceNode = new Element("source");

                            sourceNode.Add(new XAttribute("coordinate", source.coordinate));

                            if (!string.ReferenceEquals(source.owner, null))
                            {
                                sourceNode.Add(new XAttribute("owner", source.owner));
                            }

                            sourceNode.Add(new XAttribute("procedure", source.name));

                            Element targetNode = new Element("target");

                            targetNode.Add(new XAttribute("coordinate", target.coordinate));

                            if (!string.ReferenceEquals(target.owner, null))
                            {
                                targetNode.Add(new XAttribute("owner", target.owner));
                            }

                            targetNode.Add(new XAttribute("procedure", target.name));

                            relationNode.Add(sourceNode);
                            relationNode.Add(targetNode);

                            bool append = true;
                            IEnumerator <Element> iter = dlineageRelation.Elements().GetEnumerator();
                            while (iter.MoveNext())
                            {
                                if (iter.Current.Equals(relationNode))
                                {
                                    append = false;
                                    break;
                                }
                            }
                            if (append)
                            {
                                dlineageRelation.Add(relationNode);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        private static Element GetFailMessageElements(IComparerResult comparerResult)
        {
            Element element = new Element(string.Format("{0} {1}", comparerResult.ResultContext, comparerResult.Name));

            element.Add("Added Elements:", comparerResult.AddedItems.Select(added => string.Format("{0} -- {1}", added.ItemName, added.ResultContext)));
            element.Add("Removed Elements:", comparerResult.RemovedItems.Select(removed => string.Format("{0} -- {1}", removed.ItemName, removed.ResultContext)));
            element.Add("Changed Flags:", comparerResult.ChangedFlags.Select(changed => string.Format("{0} from {1} to {2}", changed.PropertyName, changed.ReferenceValue, changed.NewValue)));
            element.Add("Changed Attributes:", comparerResult.ChangedProperties.Select(changed => string.Format("{0} from {1} to {2}", changed.PropertyName, changed.ReferenceValue, changed.NewValue)));
            element.Add("Changed Children:", comparerResult.ComparerResults.Select(GetFailMessageElements));
            return(element.HasElements ? element : null);
        }
Exemplo n.º 3
0
        private static Element GetFailMessageElements(IComparerResult comparerResult)
        {
            Element element = new Element(string.Format("{0} {1}", comparerResult.ResultContext, comparerResult.Name));

            element.Add("Added Elements:", comparerResult.AddedItems.Select(added => string.Format("{0} -- {1} ({2})", added.ItemName, added.ResultContext, added.Severity)));
            element.Add("Removed Elements:", comparerResult.RemovedItems.Select(removed => string.Format("{0} -- {1} ({2})", removed.ItemName, removed.ResultContext, removed.Severity)));
            element.Add("Changed Flags:", comparerResult.ChangedFlags.Select(changed => string.Format("{0} from {1} to {2} ({3})", changed.PropertyName, changed.ReferenceValue, changed.NewValue, changed.Severity)));
            element.Add("Changed Attributes:", comparerResult.ChangedProperties.Select(changed => string.Format("{0} from {1} to {2} ({3})", changed.PropertyName, changed.ReferenceValue, changed.NewValue, changed.Severity)));

            // Do not list child elements for assemblies because all of the children will be placed in a separate test
            if (comparerResult.ResultContext != ResultContext.Assembly)
            {
                element.Add("Changed Children:", comparerResult.ComparerResults.Select(GetFailMessageElements));
            }
            return(element.HasElements ? element : null);
        }
Exemplo n.º 4
0
        public async Task Base64Test()
        {
            Element tree1 = new Element(Data.FromInt(0x0), null);

            Element ch_A = new Element(Data.FromInt(0x100), null);
            Element ch_B = new Element(Data.FromInt(0x200), null);
            Element ch_C = new Element(Data.FromInt(0x300), null);

            tree1.Add(ch_A, ch_B, ch_C);

            Element ch_A_1 = new Element(Data.FromInt(0x110), null);
            Element ch_A_2 = new Element(Data.FromInt(0x120), null);

            ch_A.Add(ch_A_1, ch_A_2);

            Element ch_C_1 = new Element(Data.FromInt(0x310), null);
            Element ch_C_2 = new Element(Data.FromInt(0x320), null);
            Element ch_C_3 = new Element(Data.FromInt(0x330), null);
            Element ch_C_4 = new Element(Data.FromInt(0x340), Data.FromAsciiString("123456789"));

            ch_C.Add(ch_C_1, ch_C_2, ch_C_3, ch_C_4);

            Element ch_C_3_I = new Element(Data.FromInt(0x331), null);

            ch_C_3.Add(ch_C_3_I);

            string base64String = await tree1.ToBase64StringAsync().ConfigureAwait(false);

            Element tree2 = await Element.FromBase64StringAsync(base64String).ConfigureAwait(false);

            Assert.AreEqual(tree1.TreeToString(), tree2.TreeToString());
        }
Exemplo n.º 5
0
 public void CanAddSubElements()
 {
     var e2 = new Element("E2");
     var element = new Element("El");
     element.Add(e2);
     Assert.That(element.Elements.Contains(e2));
 }
Exemplo n.º 6
0
 /// <summary>
 /// add some item to the itemset, use , to separate the items
 /// </summary>
 /// <param name="items"></param>
 public void AddItems(params T[] items)
 {
     foreach (var item in items)
     {
         Element.Add(item);
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// init function,provide the all the item one by one use , to separate
 /// this is how key word params used
 /// </summary>
 /// <param name="items"></param>
 public Itemset(params T[] items)
 {
     foreach (var item in items)
     {
         Element.Add(item);
     }
 }
Exemplo n.º 8
0
        /// <summary>
        /// Initializes a new instance of the Message class
        /// </summary>
        /// <param name="attributes">The Message body</param>
        public Message(object attributes)
            : this()
        {
            Element.Add();

            AddAttributesFromObject(attributes);
        }
Exemplo n.º 9
0
        public BinaryFormatterKeyManager(BinaryReader objBinaryReader)
            : this()
        {
            if (objBinaryReader == null)
            {
                throw new ArgumentNullException("objBinaryReader", "The binary reader must represent a valid instance.");
            }

            byte objDataType = 0;

            while ((objDataType = objBinaryReader.ReadByte()) != EndDataType)
            {
                string strKey   = objBinaryReader.ReadString();
                string strValue = objBinaryReader.ReadString();

                switch (objDataType)
                {
                case (TypeRecordType):
                    Type.Add(strKey, strValue);
                    break;

                case (AssemblyRecordType):
                    Assembly.Add(strKey, strValue);
                    break;

                case (ElementRecordType):
                    Element.Add(strKey, strValue);
                    break;

                default:
                    break;
                }
            }
        }
Exemplo n.º 10
0
 /// <summary>
 /// Sets the value of an element attribute
 /// </summary>
 /// <param name="key"></param>
 /// <param name="value"></param>
 public void SetAttributeValue(string key, object value)
 {
     if (AllowedAttributes.Contains(key))
     {
         Element.Add(new XAttribute(key, value));
     }
 }
Exemplo n.º 11
0
        public static Func <IWorkshopTree, IWorkshopTree, IWorkshopTree> DefaultFromOperator(TypeOperator op)
        {
            switch (op)
            {
            case TypeOperator.Add: return((l, r) => Element.Add(l, r));

            case TypeOperator.And: return((l, r) => Element.And(l, r));

            case TypeOperator.Divide: return((l, r) => Element.Divide(l, r));

            case TypeOperator.Modulo: return((l, r) => Element.Modulo(l, r));

            case TypeOperator.Multiply: return((l, r) => Element.Multiply(l, r));

            case TypeOperator.Or: return((l, r) => Element.Or(l, r));

            case TypeOperator.Pow: return((l, r) => Element.Pow(l, r));

            case TypeOperator.Subtract: return((l, r) => Element.Subtract(l, r));

            case TypeOperator.Equal: return((l, r) => Element.Compare(l, Elements.Operator.Equal, r));

            case TypeOperator.GreaterThan: return((l, r) => Element.Compare(l, Elements.Operator.GreaterThan, r));

            case TypeOperator.GreaterThanOrEqual: return((l, r) => Element.Compare(l, Elements.Operator.GreaterThanOrEqual, r));

            case TypeOperator.LessThan: return((l, r) => Element.Compare(l, Elements.Operator.LessThan, r));

            case TypeOperator.LessThanOrEqual: return((l, r) => Element.Compare(l, Elements.Operator.LessThanOrEqual, r));

            case TypeOperator.NotEqual: return((l, r) => Element.Compare(l, Elements.Operator.NotEqual, r));

            default: throw new NotImplementedException(op.ToString());
            }
        }
Exemplo n.º 12
0
        public void Run()
        {
            var screenBitmap = new Bitmap(_screen.Screen, 800, 600, 800 * 4);
            var desktop      = new BitmapRenderer(screenBitmap);
            var screen       = new BitmapRenderer(screenBitmap);
            var root         = new Element();

            root.Add(new Box(screenBitmap.Area, 0xff404040));

            while (_power.On)
            {
                screen.Draw(Cursor, new Point(_mouse.X, _mouse.Y));
                //_screen.Screen[_mouse.X + _mouse.Y * 320] = 255;

                _screen.VRetrace();
                root.Render(desktop);

                foreach (Elements.App app in _apps)
                {
                    foreach (Window window in app.Windows)
                    {
                        window.Render(desktop);
                    }
                }
            }
        }
Exemplo n.º 13
0
        public void CanRetrieveNearestElement()
        {
            var root = new Element();
            var e2 = new Element("E2", ">");
            var e3 = new Element("#yahoo");
            var e1 = new Element(".hello");
            var e1_sibling = new Element(".goodbye");
            var e1_siblingb = new Element(".helloAgain");
            root.Add(e1);
            root.Add(e1_sibling);
            root.Add(e1_siblingb);
            root.Add(new Variable("@RootVariable", new Color(1, 1, 1)));
            e1.Add(e2);
            e2.Add(e3);
            e2.Add(new Variable("@Variable", new Color(1, 1, 1)));
            e2.Add(new Variable("@NumVariable", new Number(10)));
            var nearestEl = e3.Nearest("@Variable");
            Assert.AreEqual(nearestEl.ToString(), "@Variable");

            //TODO: Remove this nonsense it isnt a test its just to see ToCSS output
            var nodes = new List<INode>
                            {
                                new Variable("@Variable", new Color(1, 1, 1)),
                                new Operator("+"),
                                new Number(2)
                            };
            e1.Add(new Property("color", nodes));
            e1_sibling.Add(new Property("color", nodes));
            e1_siblingb.Add(new Property("color", nodes));
            var nodesb = new List<INode>
                            {
                                new Number("px", 4),
                                new Operator("*"),
                                new Variable("@NumVariable")
                            };

            e2.Add(new Property("padding", nodesb));

            var nodesc = new List<INode>
                            {
                                new Variable("@RootVariable", new Color(1, 1, 1)),
                                new Operator("+"),
                                new Variable("@Variable", new Color(1, 1, 1))
                            };
            e3.Add(new Property("background-color", nodesc));
            Console.WriteLine(root.Group().ToCss());
        }
 public XElement GetElement()
 {
     foreach (var Subject in Subjects)
     {
         Element.Add(new XElement("Subject", EnumHelper.GetDescription(Subject)));
     }
     return(Element);
 }
Exemplo n.º 15
0
 /// <summary>
 /// Creates a new attribute on an <see cref="Element"/>. This method is intended for <see cref="ICodec"/> implementers and should not be directly called from any other code.
 /// </summary>
 /// <param name="elem">The Element to add to.</param>
 /// <param name="key">The name of the attribute. Must be unique on the Element.</param>
 /// <param name="defer_offset">The location in the encoded DMX stream at which this Attribute's value can be found.</param>
 public static void AddDeferredAttribute(Element elem, string key, long offset)
 {
     if (offset <= 0)
     {
         throw new ArgumentOutOfRangeException("offset", "Address must be greater than 0.");
     }
     elem.Add(key, offset);
 }
Exemplo n.º 16
0
 /// <summary>
 /// standard_ruleset: ws selectors [{] ws primary ws [}] ws;
 /// </summary>
 /// <param name="element"></param>
 /// <param name="els"></param>
 /// <returns></returns>
 private static IList<Element> StandardSelectors(Element element, IEnumerable<Element> els)
 {
     foreach (var el in els){
         element.Add(el);
         element = element.Last;
     }
     return new List<Element> { element};
 }
Exemplo n.º 17
0
        /// <summary>
        /// Adds "point" node with "on" and "off" attributes
        /// </summary>
        /// <param name="on"></param>
        /// <param name="off"></param>
        /// <returns></returns>
        public LeaksNodeBuilder PointOnOff(string on, string off)
        {
            var node = new PointOnOffNodeBuilder(on, off);

            Element.Add(node.Element);

            return(this);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Adds "point" node with "proc" attribute
        /// </summary>
        /// <param name="proc"></param>
        /// <returns></returns>
        public LeaksNodeBuilder PointProc(string proc)
        {
            var node = new PointProcNodeBuilder(proc);

            Element.Add(node.Element);

            return(this);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Adds "point" node with "call" attribute
        /// </summary>
        /// <param name="call">"server" or "client"</param>
        /// <returns></returns>
        public LeaksNodeBuilder PointCall(string call)
        {
            var node = new PointCallNodeBuilder(call);

            Element.Add(node.Element);

            return(this);
        }
Exemplo n.º 20
0
 public void Apply(double derivative, Element <double> rhs)
 {
     if (rhs != null)
     {
         rhs.Add(derivative * Value);
     }
     _elt.Add(derivative);
 }
Exemplo n.º 21
0
        public void AddAbility(string name, int lv)
        {
            var xe = new XElement("ProfileAbilityReferences");

            xe.Add(new XAttribute("Name", name));
            xe.Add(new XAttribute("Level", lv));
            Element.Add(xe);
        }
Exemplo n.º 22
0
 public void CanRetrieveElementPath()
 {
     var e2 = new Element("E2");
     var e3 = new Element("E3");
     var element = new Element("El");
     element.Add(e2);
     e2.Add(e3);
     Assert.That(e3.Path().Contains(element));
 }
Exemplo n.º 23
0
        /// <summary>
        /// Adds "dump" node
        /// </summary>
        /// <param name="builder"></param>
        /// <returns></returns>
        public ConfigNodeBuilder Dump(Action <DumpNodeBuilder> builder)
        {
            var node = new DumpNodeBuilder();

            builder(node);
            Element.Add(node.Element);

            return(this);
        }
Exemplo n.º 24
0
        /// <summary>
        /// Adds "Property" node
        /// </summary>
        /// <param name="name">Property name</param>
        /// <param name="builder"></param>
        /// <returns></returns>
        public LogNodeBuilder Property(string name, Action <PropertyNodeBuilder> builder)
        {
            var node = new PropertyNodeBuilder(name);

            builder?.Invoke(node);
            Element.Add(node.Element);

            return(this);
        }
            public override VisualElement Build()
            {
                var root = new Element <LifecycleContent> {
                    m_Content = Target
                };

                root.Add(new Label("Hello"));
                return(root);
            }
Exemplo n.º 26
0
        /// <summary>
        /// Adds "Query" node
        /// </summary>
        /// <param name="builder"></param>
        /// <returns></returns>
        public ConfigNodeBuilder Query(bool checkActualNullable)
        {
            var node = new QueryNodeBuilder();

            node.CheckActualNullable = checkActualNullable;
            Element.Add(node.Element);

            return(this);
        }
Exemplo n.º 27
0
        public override bool TryGetMember(GetMemberBinder binder, out object result)
        {
            var name  = GetName(binder.Name);//TODO@personball deal with numbers
            var child = new XElement(name);

            Element.Add(child);
            result = new XmlDynamicConstructor(child, _root);
            return(true);
        }
Exemplo n.º 28
0
            public bool TryAddNewTarget(string tag, AIState state, float priority, out TargetParams targetParams)
            {
                var element = TargetParams.CreateNewElement(tag, state, priority);

                if (TryAddTarget(element, out targetParams))
                {
                    Element.Add(element);
                }
                return(targetParams != null);
            }
            public void AddItem(string identifier = null)
            {
                identifier = identifier ?? "";
                var element = new XElement("item", new XAttribute("identifier", identifier));

                Element.Add(element);
                var item = new InventoryItem(element, Character);

                SubParams.Add(item);
                Items.Add(item);
            }
Exemplo n.º 30
0
        /// <summary>
        /// Adds "Ftextupd" node
        /// </summary>
        /// <param name="builder"></param>
        /// <returns></returns>
        public ConfigNodeBuilder Ftextupd(bool logFiles)
        {
            var node = new FtextupdNodeBuilder
            {
                Logfiles = logFiles
            };

            Element.Add(node.Element);

            return(this);
        }
Exemplo n.º 31
0
        private EventNodeBuilder AddFilter(string tag, string property, string value)
        {
            var elem = new XElement(tag);

            elem.Add(new XAttribute("property", property));
            elem.Add(new XAttribute("value", value));

            Element.Add(elem);

            return(this);
        }
        protected override void OnSetupReady()
        {
            m_Hidden = new VisualElement();
            m_Hidden.Hide();

            m_Visible = new VisualElement();
            m_Visible.Show();

            Element.Add(m_Hidden);
            Element.Add(m_Visible);
        }
Exemplo n.º 33
0
 public XElement GetElement()
 {
     if (Disambiguate == false)
     {
         Element.SetAttributeValue("Disambiguate", Disambiguate);
     }
     foreach (var phrase in Phrases)
     {
         Element.Add(new XElement(Schema + "Item", phrase));
     }
     return(Element);
 }
Exemplo n.º 34
0
        /// <summary>
        /// Adds "DefaultLog" node
        /// </summary>
        /// <param name="builder"></param>
        /// <returns></returns>
        public ConfigNodeBuilder DefaultLog(string location, int history)
        {
            var node = new DefaultLogNodeBuilder
            {
                Location = location,
                History  = history
            };

            Element.Add(node.Element);

            return(this);
        }
Exemplo n.º 35
0
        /// <summary>
        /// declaration:  standard_declaration / catchall_declaration ;
        /// </summary>
        /// <param name="node"></param>
        /// <param name="element"></param>
        private void Declaration(PegNode node, Element element)
        {
            if (node.id_.ToEnLess() == EnLess.standard_declaration)
            {
                node = node.child_;
                var name = node.GetAsString(Src).Replace(" ", "");

                if (name.Substring(0, 1) == "@")
                {
                    var property = new Variable(name, Expressions(node.next_, element));
                    element.Add(property);
                }
                else
                {
                    var property = new Property(name, Expressions(node.next_, element));
                    element.Add(property);
                }
            }
            else if (node.id_.ToEnLess() == EnLess.catchall_declaration)
            {
            /*                node = node.child_;
                var name = node.GetAsString(Src).Replace(" ", "");
                element.Add(new Property(name));*/

                //TODO: Should I be doing something here?
            }
        }
Exemplo n.º 36
0
        public Datamodel Decode(int encoding_version, string format, int format_version, Stream stream, DeferredMode defer_mode)
        {
            stream.Seek(0, SeekOrigin.Begin);
            while (true)
            {
                var b = stream.ReadByte();
                if (b == 0) break;
            }
            var dm = new Datamodel(format, format_version);

            EncodingVersion = encoding_version;
            Reader = new BinaryReader(stream, Datamodel.TextEncoding);

            if (EncodingVersion >= 9)
            {
                // Read prefix elements
                foreach (int prefix_elem in Enumerable.Range(0, Reader.ReadInt32()))
                {
                    foreach (int attr_index in Enumerable.Range(0, Reader.ReadInt32()))
                    {
                        var name = ReadString_Raw();
                        var value = DecodeAttribute(dm);
                        if (prefix_elem == 0) // skip subsequent elements...are they considered "old versions"?
                            dm.PrefixAttributes[name] = value;
                    }
                }
            }

            StringDict = new StringDictionary(this, Reader);
            var num_elements = Reader.ReadInt32();

            // read index
            foreach (var i in Enumerable.Range(0, num_elements))
            {
                var type = StringDict.ReadString();
                var name = EncodingVersion >= 4 ? StringDict.ReadString() : ReadString_Raw();
                var id_bits = Reader.ReadBytes(16);
                var id = new Guid(BitConverter.IsLittleEndian ? id_bits : id_bits.Reverse().ToArray());

                var elem = new Element(dm, name, id, type);
            }

            // read attributes (or not, if we're deferred)
            foreach (var elem in dm.AllElements.ToArray())
            {
                System.Diagnostics.Debug.Assert(!elem.Stub);

                var num_attrs = Reader.ReadInt32();

                foreach (var i in Enumerable.Range(0, num_attrs))
                {
                    var name = StringDict.ReadString();

                    if (defer_mode == DeferredMode.Automatic)
                    {
                        CodecUtilities.AddDeferredAttribute(elem, name, Reader.BaseStream.Position);
                        SkipAttribte();
                    }
                    else
                    {
                        elem.Add(name, DecodeAttribute(dm));
                    }
                }
            }
            return dm;
        }
Exemplo n.º 37
0
 /// <summary>
 /// Creates a new attribute on an <see cref="Element"/>. This method is intended for <see cref="ICodec"/> implementers and should not be directly called from any other code.
 /// </summary>
 /// <param name="elem">The Element to add to.</param>
 /// <param name="key">The name of the attribute. Must be unique on the Element.</param>
 /// <param name="defer_offset">The location in the encoded DMX stream at which this Attribute's value can be found.</param>
 public static void AddDeferredAttribute(Element elem, string key, long offset)
 {
     if (offset <= 0) throw new ArgumentOutOfRangeException("offset", "Address must be greater than 0.");
     elem.Add(key, offset);
 }
Exemplo n.º 38
0
 protected virtual Generic.IEnumerator<Node> Process(Element element)
 {
     Element result = new Element(element.Name, this.Process(element.Attributes.GetEnumerator())) { Region = element.Region };
     foreach (Node node in element)
         this.Process(node).Apply(n =>
         {
             if (n.NotNull())
                 result.Add(n);
         });
     yield return result;
 }
Exemplo n.º 39
0
 /// <summary>
 /// standard_ruleset: ws selectors [{] ws primary ws [}] ws;
 /// </summary>
 /// <param name="element"></param>
 /// <param name="els"></param>
 /// <returns></returns>
 private static IEnumerable<Element> StandardSelectors(Element element, IEnumerable<Element> els)
 {
     foreach (var el in els)
     {
         element.Add(el);
         element = element.Last;
     }
     yield return element;
 }
Exemplo n.º 40
0
        private IEnumerable<INode> Insert(PegNode node, Element element)
        {
            node = (node.child_ ?? node);
            var path = (node).GetAsString(Src)
                .Replace("\"", "").Replace("'", "");

            if (HttpContext.Current != null){
                path = HttpContext.Current.Server.MapPath(path);
            }

            if (File.Exists(path)){
                var text = File.ReadAllText(path);
                element.Add(new Insert(text));
            }
            return new List<INode>();
        }
Exemplo n.º 41
0
        /// <summary>
        /// declaration:  standard_declaration / catchall_declaration ;
        /// </summary>
        /// <param name="node"></param>
        /// <param name="element"></param>
        private void Declaration(PegNode node, Element element)
        {
            var name = node.GetAsString(Src).Replace(" ", "");
            var nextNode = node.next_;

            if(nextNode == null){
                // TODO: emit warning: empty declaration //
                return;
            }
            if (nextNode.ToEnLess() == EnLess.comment)
                nextNode = nextNode.next_;

            var values = Expressions(nextNode, element);
            var property = name.StartsWith("@") ? new Variable(name, values) : new Property(name, values);
            element.Add(property);
        }