Пример #1
0
        private void VisitNodes(GeneralTree<INode> features, INode node)
        {
            if (node.IsIndexMarkDownNode())
            {
                return;
            }

            string nodePath = this.fileSystem.Path.Combine(this.configuration.OutputFolder.FullName, node.RelativePathFromRoot);
            string htmlFilePath;

            if (node.NodeType == NodeType.Content)
            {
                htmlFilePath = nodePath.Replace(this.fileSystem.Path.GetExtension(nodePath), ".html");
                this.WriteContentNode(features, node, htmlFilePath);
           }
            else if (node.NodeType == NodeType.Structure)
            {
                this.fileSystem.Directory.CreateDirectory(nodePath);

                htmlFilePath = this.fileSystem.Path.Combine(nodePath, "index.html");
                this.WriteContentNode(features, node, htmlFilePath);
            }
            else
            {
                // copy file from source to output
                this.fileSystem.File.Copy(node.OriginalLocation.FullName, nodePath, overwrite: true);
            }
        }
Пример #2
0
        public IEnumerable<NodeConnection> GetPossibleTransitions(INode from)
        {
            var wsFrom = ((WorldStateNode)from).State;

            var result = new List<NodeConnection>();

            foreach (var action in planner.Actions)
            {
                var pre = action.Preconditions;
                var mask = pre.Mask;

                var met = (pre.Values & mask) == (wsFrom.Values & mask);
                if (met)
                {
                    var neighbour = planner.PerformAction(action, wsFrom);

                    if (wsFrom.Match(neighbour))
                    {
                        continue;
                    }

                    var connection = new NodeConnection();
                    connection.From = from;
                    connection.To = new WorldStateNode(this, neighbour, action);
                    connection.Cost = action.Cost;

                    result.Add(connection);
                }
            }

            return result;
        }
Пример #3
0
		// inserting before current position is not allowed in a Transformer
		// but inserting after it is possible
		protected void InsertAfterSibling(INode sibling, INode newNode)
		{
			if (sibling == null || sibling.Parent == null) return;
			int index = sibling.Parent.Children.IndexOf(sibling);
			sibling.Parent.Children.Insert(index + 1, newNode);
			newNode.Parent = sibling.Parent;
		}
        private static void PrintSolution(PathFinder pathFinder, INode result)
        {
            int steps = 0;
            INode node = result;

            if (node != null)
            {
                var stack = new Stack<INode>();

                do
                {
                    stack.Push(node);
                } while ((node = node.Parent) != null);

                Debug.WriteLine("8-Puzzle Solved in {0} Cycles", pathFinder.Cycles);
                Debug.WriteLine("-------------------------------------------");

                foreach (EightPuzzleNode solutionNode in stack)
                {
                    string tiles = solutionNode.Tiles
                        .Aggregate("", (current, i) => current + i.ToString());

                    Debug.WriteLine("{0:00} - {1} -  F: {2:00.0}  G: {3:00.0}  H: {4:00.0}",
                                    steps++,
                                    tiles,
                                    solutionNode.F, solutionNode.G, solutionNode.H);
                }
            }
            else
            {
                Debug.WriteLine("No solution");
            }
        }
Пример #5
0
 public AStarNode(Location location, INode parent,
     decimal costFromStart, decimal costToGoal)
     : base(location, parent)
 {
     CostFromStart = costFromStart;
     CostToGoal = costToGoal;
 }
Пример #6
0
 public bool AttemptConnect(string host, string portStr)
 {
     try
     {
         var port = Int32.Parse(portStr);
         RemoteHost = NodeBuilder.BuildNode().Host(host).WithPort(port).WithTransportType(TransportType.Tcp);
         Connection =
             new ClientBootstrap()
                 .SetTransport(TransportType.Tcp)
                 .RemoteAddress(RemoteHost)
                 .OnConnect(ConnectionEstablishedCallback)
                 .OnReceive(ReceivedDataCallback)
                 .OnDisconnect(ConnectionTerminatedCallback)
                 .Build().NewConnection(NodeBuilder.BuildNode().Host(IPAddress.Any).WithPort(10001), RemoteHost);
         Connection.Open();
         return true;
     }
     catch (Exception ex)
     {
         AppendStatusText(ex.Message);
         AppendStatusText(ex.StackTrace);
         AppendStatusText(ex.Source);
         return false;
     }
 }
 public SearcherResult(DateTime startTimeStamp, INode resultNode, string path, SearchOptions searchOptions)
 {
     StartTimestamp = startTimeStamp;
     ResultNode = resultNode;
     Path = path;
     SearchOptions = searchOptions;
 }
Пример #8
0
        readonly int selectedIndex; // the implementation that is bound

        public Subplan(INode n, int selectedIndex, InjectionPlan[] alternatives)
            : base(n)
        {
            this.alternatives = alternatives;
            if (selectedIndex < -1 || selectedIndex >= alternatives.Length)
            {
                Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(new IndexOutOfRangeException(), LOGGER);
            }
            this.selectedIndex = selectedIndex;
            if (selectedIndex != -1)
            {
                // one was bound
                this.numAlternatives = alternatives[selectedIndex].GetNumAlternatives();
            }
            else
            {
                // no one was bound, but anyone could be used
                int numAlternatives = 0;
                foreach (InjectionPlan a in alternatives)
                {
                    numAlternatives += a.GetNumAlternatives();
                }
                this.numAlternatives = numAlternatives;
            }
        }
Пример #9
0
 public QuickRemove(ToolStripMenuItem menu, IGraph g, INode objNode, String file)
 {
     this._menu = menu;
     this._g = g;
     this._objNode = objNode;
     this._file = file;
 }
Пример #10
0
        protected override void LoadProperties(Content.IContentManager contentManager, INode node)
        {
            base.LoadProperties(contentManager, node);

            CirclePrimitive circlePrimitive = (CirclePrimitive)node;
            circlePrimitive.Radius = Radius;
        }
Пример #11
0
 public Transition(string identifier, bool isDefault, INode source, INode destination)
 {
     IsDefault = isDefault;
     Source = source;
     Destination = destination;
     Identifier = identifier;
 }
Пример #12
0
 internal static void Add(Identifier identifier, INode node)
 {
     if (_symbols.ContainsKey(identifier.Name))
         _symbols[identifier.Name] = node;
     else
         _symbols.Add(identifier.Name, node);
 }
Пример #13
0
		public void Run(INode typeDeclaration)
		{
			typeDeclaration.AcceptVisitor(this, null);
			foreach (VariableDeclaration decl in fields) {
				decl.Name = prefix + decl.Name;
			}
		}
Пример #14
0
        public ImportSymbolSelectionDlg(INode[] nodes)
        {
            this.Build ();

            SetResponseSensitive(ResponseType.Ok, true);
            SetResponseSensitive(ResponseType.Cancel, true);

            buttonOk.GrabFocus();
            Modal = true;
            WindowPosition = Gtk.WindowPosition.CenterOnParent;

            // Init name column
            var nameCol = new TreeViewColumn();
            var textRenderer = new CellRendererText();
            nameCol.PackStart(textRenderer, true);
            nameCol.AddAttribute(textRenderer, "text", 0);
            list.AppendColumn(nameCol);

            // Init list model
            var nodeStore = new ListStore(typeof(string),typeof(INode));
            list.Model = nodeStore;

            // Fill list
            foreach (var n in nodes)
                if(n!=null)
                    nodeStore.AppendValues(n.ToString(), n);

            // Select first result
            TreeIter iter;
            if(nodeStore.GetIterFirst(out iter))
                list.Selection.SelectIter(iter);
        }
Пример #15
0
 internal SetPropertyValueOperation(INode node, string name, object oldvalue, object newvalue)
 {
     this.node = node;
     this.name = name;
     this.oldvalue = oldvalue;
     this.newvalue = newvalue;
 }
Пример #16
0
	/* Pushes a node on to the stack. */
	internal virtual void  pushNode(INode n) {
	    System.Object temp_object;
	    temp_object = n;
	    System.Object generatedAux = temp_object;
	    nodes.Push(temp_object);
	    ++sp;
	}
Пример #17
0
 public void OnFocusedNodeChanged(INode inode)
 {
     if (focusedNodeChanged != null)
     {
         focusedNodeChanged(this, inode);
     }
 }
        //private List<MovieDictionaryItem> MoviesDictionary { get; set; }
        private void LookupMovieAtCinemas(INode cinemasNode, MovieDictionaryItem movieDictionaryItem)
        {
            foreach (INode cityNode in cinemasNode.ChildrenAsList)
            {
                var cityDictionary = new CityDictionaryItem();
                cityDictionary.Cinemas = new List<CinemaDictionaryItem>();
                cityDictionary.CityName = cityNode.Name;

                foreach (INode cinemaNode in cityNode.ChildrenAsList)
                {
                    var cinema = ModelFactory.CreateModel<Cinema>(cinemaNode);
                    foreach (var program in cinema.MoviePrograms)
                    {
                        if (program.MovieLink.NodeId == movieDictionaryItem.MovieNodeId)
                        {
                            cityDictionary.Cinemas.Add(new CinemaDictionaryItem() { Name = cinema.Name, NodeUrl = cinema.NodeUrl });
                            break;
                        }
                    }
                }
                if (cityDictionary.Cinemas.Count > 0)
                {
                    if (movieDictionaryItem.Cities == null)
                        movieDictionaryItem.Cities = new List<CityDictionaryItem>();
                    movieDictionaryItem.Cities.Add(cityDictionary);
                }
            }
        }
Пример #19
0
        public XElement Format(INode contentNode, IEnumerable<INode> features)
        {
            var featureItemNode = contentNode as FeatureNode;
            if (featureItemNode != null)
            {
                var formattedContent = this.htmlFeatureFormatter.Format(featureItemNode.Feature);
                this.htmlImageRelocator.Relocate(contentNode, formattedContent);
                return formattedContent;
            }

            var indexItemNode = contentNode as FolderNode;
            if (indexItemNode != null)
            {
                return this.htmlIndexFormatter.Format(indexItemNode, features);
            }

            var markdownItemNode = contentNode as MarkdownNode;
            if (markdownItemNode != null)
            {
                this.htmlImageRelocator.Relocate(contentNode, markdownItemNode.MarkdownContent);
                return markdownItemNode.MarkdownContent;
            }

            throw new InvalidOperationException("Cannot format a FeatureNode with a Type of " + contentNode.GetType() +
                                                " as content");
        }
Пример #20
0
        ////数字节点只能是叶子。
        //public GeneralNode(double number_p)
        //{
        //    number = number_p;
        //    left = right = null;
        //    isNumber = true;
        //    symbol = Esymbol.Nothing;
        //    priority = Epriority.Nothing;
        //}
        //操作符节点初始化
        public void SetUpNode(params object[] paras)//Esymbol symbol_p, INode left_p, INode right_p)
        {
            if (paras != null && paras.Length == 4)
            {
                if (paras[0] != null)
                {
                    number = (double)paras[0];
                    isNumber = true;
                }
                else
                {
                    isNumber = false;
                }

                left = (INode)paras[1];
                right = (INode)paras[2];

                if (paras[3] != null)
                {
                    symbol = (Esymbol)paras[3];
                }
                else
                {
                    symbol = Esymbol.Nothing;
                }

                priority = this.SymbolInPriority(symbol);
            }
            else
                throw new Exception("Node初始化参数数量对!");
        }
Пример #21
0
 public LinkBehavior(XmlAttributeCollection collection)
     : base(collection)
 {
     fileNode = null;
     contextNode = null;
     typeNode = null;
 }
 public IEnumerable<Triple> GetTriplesWithSubjectPredicate(INode subj, INode pred)
 {
     Document lookup = new Document();
     lookup["graph.subject"] = this._formatter.Format(subj);
     lookup["graph.predicate"] = this._formatter.Format(pred);
     return new MongoDBGraphCentricEnumerable(this._manager, lookup, t => t.Subject.Equals(subj) && t.Predicate.Equals(pred));
 }
Пример #23
0
 public static string GetUriStringForNode(INode node)
 {
     if (node.IsEmpty()) return string.Empty;
     return string.Format("{0}://{1}:{2}", GetProtocolStringForTransportType(node.TransportType),
         GetHostStringForAddress(node.Host),
         node.Port);
 }
Пример #24
0
        public override INode AddNode(INode currentParent, IConverter converter)
        {
            INode orNode = new OrNode(converter);

            //// First element of a chain
            //if (currentParent is RootNode)
            //    throw new NotImplementedException("Or cannot be the first element");

            // Insert at root
            if (currentParent is RootNode)
            {
                var root = (currentParent as RootNode);
                var firstChild = root.Children.First();
                firstChild.Parent = orNode;
                (orNode as OrNode).Children.Add(firstChild);
                orNode.Parent = root;
                root.Children.Remove(firstChild);
            }
            // Insert before its parent
            else if (currentParent.Parent != null && currentParent.Parent as IMotherNode != null)
            {
                var grandParent = currentParent.Parent as IMotherNode;
                grandParent.Children.Remove(currentParent);
                (orNode as OrNode).Children.Add(currentParent);
                currentParent = currentParent.Parent;
            }

            this.LinkNodeToParent(currentParent, orNode);
            return orNode;
        }
Пример #25
0
		public static string ToText(INode node)
		{
			var output = new CSharpOutputVisitor();
			node.AcceptVisitor(output, null);

			return output.Text;
		}
Пример #26
0
        INode INodeCreator.CreateNode(Session session, INode parent, string name, IEnumerable<Property> properties)
        {
            if (parent != null && parent.ChildNodes[name] != null)
                throw new InvalidOperationException("Duplicated Child Node Name");

            return new Node(session, parent, name, properties, this.store);
        }
		protected override void EndVisit(INode node)
		{
			if (node is PropertyGetRegion || node is PropertySetRegion) {
				this.currentContext = VisitorContext.Default;
			}
			base.EndVisit(node);
		}
Пример #28
0
		public override bool DoMatch(INode other, Match match)
		{
			if (other == null || other.IsNull)
				return this.MinCount <= 0;
			else
				return this.MaxCount >= 1 && childNode.DoMatch(other, match);
		}
Пример #29
0
        IExpressionNode CreateNode(INode node)
        {
            IExpressionNode expressionNode = null;

            if (node is ExpressionStatement)
            {
                var statementNode = (ExpressionStatement)node;
                expressionNode = new StatementExpressionNode
                {
                    Expression = CreateNode(statementNode.Expression)
                };
            }
            else if (node is BinaryOperatorExpression)
            {
                var binaryNode = ((BinaryOperatorExpression)node);
                expressionNode = new BinaryExpressionNode
                {
                    Operator = (BinaryExpressionNode.Operators)binaryNode.Op,
                    Left = CreateNode(binaryNode.Left),
                    Right = CreateNode(binaryNode.Right),
                };
            }
            else if (node is PrimitiveExpression)
            {
                var primitiveNode = (PrimitiveExpression)node;
                var valueType = primitiveNode.Value == null ? typeof(object) : primitiveNode.Value.GetType();
                var value = (IValueNode)Activator.CreateInstance(typeof(ValueNode<>).MakeGenericType(valueType), primitiveNode.Value);
                expressionNode = new ValueExpressionNode
                {
                    Value = value,
                };
            }

            return expressionNode;
        }
Пример #30
0
        public override INode AddNode(INode currentParent, IConverter converter)
        {
            //If the current parent is neither the root nor a group
            if(!(currentParent is IMotherNode))
                throw new ArgumentException("Trying to insert an 'AS' node, but the current node's type '" + currentParent.GetType() + "' is illegal. " + CheckString);

            GroupNode group;

            //If the current parent is the root
            if (currentParent is RootNode)
            {
                group = (currentParent as IMotherNode).Children.Last() as GroupNode;
                if (group == null)
                    throw new ArgumentException("Trying to insert an 'AS' node, but no Group found at root nor in its children. " + CheckString);
            }
            // The current parent is the group
            else if (currentParent is GroupNode)
                group = currentParent as GroupNode;
            // The group is the last child of the current parent
            else if ((currentParent as IMotherNode).Children.Last() is GroupNode)
                group = (currentParent as IMotherNode).Children.Last() as GroupNode;
            else
                throw new ArgumentException("Trying to insert an 'AS' node, but the current node is neither a group nor contains a group as children. " + CheckString);

            if (converter != null && converter.Function != null && converter.Function.Arguments != null && converter.Function.Arguments.Any())
                group.Name = converter.Function.Arguments[0].ToString();

            return currentParent;
        }
Пример #31
0
 public static DomRegion DomRegion(this INode node)
 {
     return(new DomRegion(node.StartLocation.Line, node.StartLocation.Column, node.EndLocation.Line, node.EndLocation.Column));
 }
Пример #32
0
 public Task AddAsync(INode Child)
 {
     throw new NotSupportedException();
 }
Пример #33
0
 public Task <bool> AcceptsParentAsync(INode Parent)
 {
     return(Task.FromResult <bool>(false));
 }
Пример #34
0
 public Task <bool> AcceptsChildAsync(INode Child)
 {
     return(Task.FromResult <bool>(false));
 }
Пример #35
0
 public Task <bool> RemoveAsync(INode Child)
 {
     return(Task.FromResult <bool>(false));
 }
Пример #36
0
        protected override bool ValidateInternal(INode focusNode, IEnumerable <INode> valueNodes, Report report)
        {
            var invalidValues = QualifiedValueNodes(focusNode, valueNodes).Skip(NumericValue);

            return(ReportFocusNode(focusNode, invalidValues, report));
        }
Пример #37
0
 internal QualifiedMaxCount(Shape shape, INode node)
     : base(shape, node)
 {
 }
Пример #38
0
        public void Visit(ElementNode node, INode parentNode)
        {
            var            typeref = Module.ImportReference(node.XmlType.GetTypeReference(Module, node));
            TypeDefinition typedef = typeref.ResolveCached();

            if (IsXaml2009LanguagePrimitive(node))
            {
                var vardef = new VariableDefinition(typeref);
                Context.Variables[node] = vardef;
                Context.Body.Variables.Add(vardef);

                Context.IL.Append(PushValueFromLanguagePrimitive(typedef, node));
                Context.IL.Emit(Stloc, vardef);
                return;
            }

            //if this is a MarkupExtension that can be compiled directly, compile and returns the value
            var compiledMarkupExtensionName = typeref
                                              .GetCustomAttribute(Module, ("Xamarin.Forms.Core", "Xamarin.Forms.Xaml", "ProvideCompiledAttribute"))
                                              ?.ConstructorArguments?[0].Value as string;
            Type compiledMarkupExtensionType;
            ICompiledMarkupExtension markupProvider;

            if (compiledMarkupExtensionName != null &&
                (compiledMarkupExtensionType = Type.GetType(compiledMarkupExtensionName)) != null &&
                (markupProvider = Activator.CreateInstance(compiledMarkupExtensionType) as ICompiledMarkupExtension) != null)
            {
                var il = markupProvider.ProvideValue(node, Module, Context, out typeref);
                typeref = Module.ImportReference(typeref);

                var vardef = new VariableDefinition(typeref);
                Context.Variables[node] = vardef;
                Context.Body.Variables.Add(vardef);

                Context.IL.Append(il);
                Context.IL.Emit(Stloc, vardef);

                //clean the node as it has been fully exhausted
                foreach (var prop in node.Properties)
                {
                    if (!node.SkipProperties.Contains(prop.Key))
                    {
                        node.SkipProperties.Add(prop.Key);
                    }
                }
                node.CollectionItems.Clear();

                Context.IL.Append(RegisterSourceInfo(Context, node));
                return;
            }

            MethodDefinition factoryCtorInfo       = null;
            MethodDefinition factoryMethodInfo     = null;
            MethodDefinition parameterizedCtorInfo = null;
            MethodDefinition ctorInfo = null;

            if (node.Properties.ContainsKey(XmlName.xArguments) && !node.Properties.ContainsKey(XmlName.xFactoryMethod))
            {
                factoryCtorInfo = typedef.AllMethods().FirstOrDefault(md => md.methodDef.IsConstructor &&
                                                                      !md.methodDef.IsStatic &&
                                                                      md.methodDef.HasParameters &&
                                                                      md.methodDef.MatchXArguments(node, typeref, Module, Context)).methodDef;
                ctorInfo = factoryCtorInfo ?? throw new BuildException(BuildExceptionCode.ConstructorXArgsMissing, node, null, typedef.FullName);
                if (!typedef.IsValueType)                 //for ctor'ing typedefs, we first have to ldloca before the params
                {
                    Context.IL.Append(PushCtorXArguments(factoryCtorInfo.ResolveGenericParameters(typeref, Module), node));
                }
            }
            else if (node.Properties.ContainsKey(XmlName.xFactoryMethod))
            {
                var factoryMethod = (string)(node.Properties[XmlName.xFactoryMethod] as ValueNode).Value;
                factoryMethodInfo = typedef.AllMethods().FirstOrDefault(md => !md.methodDef.IsConstructor &&
                                                                        md.methodDef.Name == factoryMethod &&
                                                                        md.methodDef.IsStatic &&
                                                                        md.methodDef.MatchXArguments(node, typeref, Module, Context)).methodDef;
                if (factoryMethodInfo == null)
                {
                    throw new BuildException(BuildExceptionCode.MethodStaticMissing, node, null, typedef.FullName, factoryMethod, null);
                }

                Context.IL.Append(PushCtorXArguments(factoryMethodInfo.ResolveGenericParameters(typeref, Module), node));
            }
            if (ctorInfo == null && factoryMethodInfo == null)
            {
                parameterizedCtorInfo = typedef.Methods.FirstOrDefault(md => md.IsConstructor &&
                                                                       !md.IsStatic &&
                                                                       md.HasParameters &&
                                                                       md.Parameters.All(
                                                                           pd =>
                                                                           pd.CustomAttributes.Any(
                                                                               ca =>
                                                                               ca.AttributeType.FullName ==
                                                                               "Xamarin.Forms.ParameterAttribute")));
            }
            string missingCtorParameter = null;

            if (parameterizedCtorInfo != null && ValidateCtorArguments(parameterizedCtorInfo, node, out missingCtorParameter))
            {
                ctorInfo = parameterizedCtorInfo;
                //				IL_0000:  ldstr "foo"
                Context.IL.Append(PushCtorArguments(parameterizedCtorInfo.ResolveGenericParameters(typeref, Module), node));
            }
            ctorInfo = ctorInfo ?? typedef.Methods.FirstOrDefault(md => md.IsConstructor && !md.HasParameters && !md.IsStatic);
            if (parameterizedCtorInfo != null && ctorInfo == null)
            {
                //there was a parameterized ctor, we didn't use it
                throw new BuildException(BuildExceptionCode.PropertyMissing, node, null, missingCtorParameter, typedef.FullName);
            }
            var ctorinforef          = ctorInfo?.ResolveGenericParameters(typeref, Module);
            var factorymethodinforef = factoryMethodInfo?.ResolveGenericParameters(typeref, Module);
            var implicitOperatorref  = typedef.Methods.FirstOrDefault(md =>
                                                                      md.IsPublic &&
                                                                      md.IsStatic &&
                                                                      md.IsSpecialName &&
                                                                      md.Name == "op_Implicit" && md.Parameters[0].ParameterType.FullName == "System.String");

            if (!typedef.IsValueType && ctorInfo == null && factoryMethodInfo == null)
            {
                throw new BuildException(BuildExceptionCode.ConstructorDefaultMissing, node, null, typedef.FullName);
            }

            if (ctorinforef != null || factorymethodinforef != null || typedef.IsValueType)
            {
                VariableDefinition vardef = new VariableDefinition(typeref);
                Context.Variables[node] = vardef;
                Context.Body.Variables.Add(vardef);

                ValueNode vnode = null;
                if (node.CollectionItems.Count == 1 && (vnode = node.CollectionItems.First() as ValueNode) != null &&
                    vardef.VariableType.IsValueType)
                {
                    //<Color>Purple</Color>
                    Context.IL.Append(vnode.PushConvertedValue(Context, typeref, new ICustomAttributeProvider[] { typedef },
                                                               node.PushServiceProvider(Context), false, true));
                    Context.IL.Emit(OpCodes.Stloc, vardef);
                }
                else if (node.CollectionItems.Count == 1 && (vnode = node.CollectionItems.First() as ValueNode) != null &&
                         implicitOperatorref != null)
                {
                    //<FileImageSource>path.png</FileImageSource>
                    var implicitOperator = Module.ImportReference(implicitOperatorref);
                    Context.IL.Emit(OpCodes.Ldstr, ((ValueNode)(node.CollectionItems.First())).Value as string);
                    Context.IL.Emit(OpCodes.Call, implicitOperator);
                    Context.IL.Emit(OpCodes.Stloc, vardef);
                }
                else if (factorymethodinforef != null)
                {
                    Context.IL.Emit(OpCodes.Call, Module.ImportReference(factorymethodinforef));
                    Context.IL.Emit(OpCodes.Stloc, vardef);
                }
                else if (!typedef.IsValueType)
                {
                    var ctor = Module.ImportReference(ctorinforef);
                    //					IL_0001:  newobj instance void class [Xamarin.Forms.Core]Xamarin.Forms.Button::'.ctor'()
                    //					IL_0006:  stloc.0
                    Context.IL.Emit(OpCodes.Newobj, ctor);
                    Context.IL.Emit(OpCodes.Stloc, vardef);
                }
                else if (ctorInfo != null && node.Properties.ContainsKey(XmlName.xArguments) &&
                         !node.Properties.ContainsKey(XmlName.xFactoryMethod) && ctorInfo.MatchXArguments(node, typeref, Module, Context))
                {
                    //					IL_0008:  ldloca.s 1
                    //					IL_000a:  ldc.i4.1
                    //					IL_000b:  call instance void valuetype Test/Foo::'.ctor'(bool)

                    var ctor = Module.ImportReference(ctorinforef);
                    Context.IL.Emit(OpCodes.Ldloca, vardef);
                    Context.IL.Append(PushCtorXArguments(ctor, node));
                    Context.IL.Emit(OpCodes.Call, ctor);
                }
                else
                {
                    //					IL_0000:  ldloca.s 0
                    //					IL_0002:  initobj Test/Foo
                    Context.IL.Emit(OpCodes.Ldloca, vardef);
                    Context.IL.Emit(OpCodes.Initobj, Module.ImportReference(typedef));
                }

                if (typeref.FullName == "Xamarin.Forms.Xaml.ArrayExtension")
                {
                    var visitor = new SetPropertiesVisitor(Context);
                    foreach (var cnode in node.Properties.Values.ToList())
                    {
                        cnode.Accept(visitor, node);
                    }
                    foreach (var cnode in node.CollectionItems)
                    {
                        cnode.Accept(visitor, node);
                    }

                    markupProvider = new ArrayExtension();

                    var il = markupProvider.ProvideValue(node, Module, Context, out typeref);

                    vardef = new VariableDefinition(typeref);
                    Context.Variables[node] = vardef;
                    Context.Body.Variables.Add(vardef);

                    Context.IL.Append(il);
                    Context.IL.Emit(OpCodes.Stloc, vardef);

                    //clean the node as it has been fully exhausted
                    foreach (var prop in node.Properties)
                    {
                        if (!node.SkipProperties.Contains(prop.Key))
                        {
                            node.SkipProperties.Add(prop.Key);
                        }
                    }
                    node.CollectionItems.Clear();
                    Context.IL.Append(RegisterSourceInfo(Context, node));

                    return;
                }
                Context.IL.Append(RegisterSourceInfo(Context, node));
            }
        }
Пример #39
0
 public void Visit(ValueNode node, INode parentNode)
 {
     Context.Values[node] = node.Value;
 }
Пример #40
0
 public PostalAddress(INode node) : base(node)
 {
 }
Пример #41
0
 public string GetName(INode node)
 {
     return(node.Name);
 }
Пример #42
0
 public void Visit(MarkupNode node, INode parentNode)
 {
     //At this point, all MarkupNodes are expanded to ElementNodes
 }
Пример #43
0
 public string GetTarget(INode node)
 {
     return("");
 }
Пример #44
0
 public bool SkipChildren(INode node, INode parentNode) => false;
Пример #45
0
 public string Bind(INode node)
 {
     return(string.Format("<option value=\"{0}\">{1}</option>" + Environment.NewLine, node.Id, node.Name));
 }
Пример #46
0
 public string GetUrl(INode node)
 {
     return("");
 }
 public void JoinChildNode(INode a_nodeChild)
 {
     JoinChildNode(DEFAULT_OUTPUT_NAME, a_nodeChild);
 }
Пример #48
0
 public bool IsOpen(INode node)
 {
     return(true);
 }
Пример #49
0
 internal ArcroleReference(INode arcroleRefNode)
     : base(arcroleRefNode)
 {
     this.Uri = new Uri(arcroleRefNode.GetAttributeValue("arcroleURI"));
 }
Пример #50
0
 private string getItemHtml(INode node, int depth)
 {
     return(string.Format("<div style='margin-left:{0}px;'>{1}</div>", (depth + 1) * 15, node.Name));
 }
Пример #51
0
 public bool hasProperty(INode property, INode value)
 {
     return(_model.ContainsTriple(_source, property, value));
 }
Пример #52
0
        public bool OnFrameReceived(ILink link, IFrame frame, INode parser)
        {
            var dev = link != null ? link.Device : parser;

            if (dev.Id == 2089)
            {
                STrace.Trace(typeof(DataLinkLayer).FullName, dev.Id, frame.PayloadAsString);
            }

            dev.LastPacketReceivedAt = DateTime.UtcNow;

            IMessage msg = null;

//            STrace.Debug(dev.GetType().FullName, dev.GetDeviceId(), "2Decode: " + frame.PayloadAsString);
            var sucess = dev.ExecuteOnGuard(() => msg = dev.Decode(frame), "Device decode", frame.PayloadAsString);


            if (!sucess)
            {
                return(false);
            }

            if (msg == null)
            {
                STrace.Debug(dev.GetType().FullName, dev.GetDeviceId(), String.Format("rx. {0}", Encoding.ASCII.GetString(frame.Payload)));
                return(false);
            }

            if (dev.ChecksCorrectIdFlag && (!ParserUtils.IsInvalidDeviceId(dev.GetDeviceId())) && (link != null) && (link.Device.GetDeviceId() != dev.GetDeviceId()))
            {
                STrace.Trace(dev.GetType().FullName, dev.GetDeviceId(), String.Format("Reporte ignorado por no coincidir Id Dispo: {0} con Id Link {1} Reporte: {2}", dev.GetDeviceId(), link.Device.GetDeviceId(), msg.GetPendingAsString()));
                return(false);
            }

            if (!msg.IsInvalidDeviceId())             //(!ParserUtils.IsInvalidDeviceId(dev.GetDeviceId()))
            {
                DataTransportLayer.DispatchMessage(dev, msg);
            }
            STrace.Debug(dev.GetType().FullName, dev.GetDeviceId(), String.Format("RX: '{0}'", Encoding.ASCII.GetString(frame.Payload)));
            if (!String.IsNullOrEmpty(msg.GetPendingAsString()))
            {
                STrace.Debug(dev.GetType().FullName, dev.GetDeviceId(), String.Format("TX: '{0}'", msg.GetPendingAsString()));
            }
            if (!String.IsNullOrEmpty(msg.GetPendingPostAsString()))
            {
                STrace.Debug(dev.GetType().FullName, dev.GetDeviceId(), String.Format("TX: '{0}'", msg.GetPendingPostAsString()));
            }

            var pending     = msg.GetPending();
            var pendingpost = msg.GetPendingPost();

            if ((pending == null) && (pendingpost == null))
            {
                return(false);
            }

            if (pending != null)
            {
                frame.Reuse(pending);
                if (pendingpost != null)
                {
                    frame.PostSend(pendingpost);
                }
            }
            else
            {
                frame.Reuse(pendingpost);
            }

            return(true);
        }
Пример #53
0
 public IEnumerable <Triple> listProperties(INode property)
 {
     return(_model.GetTriplesWithSubjectPredicate(_source, property));
 }
Пример #54
0
 public bool canAs(INode cls)
 {
     return(_model.ContainsTriple(_source, RDF.PropertyType, cls));
 }
Пример #55
0
        /// <see cref="BaseTreeCtrl.EnableMenuItems" />
        protected override void EnableMenuItems(TreeNode clickedNode)
        {
            BrowseOptionsMI.Enabled   = true;
            ShowReferencesMI.Enabled  = true;
            SelectMI.Visible          = m_allowPick;
            SelectSeparatorMI.Visible = m_allowPick;

            if (clickedNode != null)
            {
                // do nothing if an error is detected.
                if (m_browser.Session.KeepAliveStopped)
                {
                    return;
                }

                SelectMI.Enabled         = true;
                SelectItemMI.Enabled     = true;
                SelectChildrenMI.Enabled = clickedNode.Nodes.Count > 0;
                BrowseRefreshMI.Enabled  = true;

                ReferenceDescription reference = clickedNode.Tag as ReferenceDescription;

                if (reference != null)
                {
                    BrowseMI.Enabled         = (reference.NodeId != null && !reference.NodeId.IsAbsolute);
                    ViewAttributesMI.Enabled = true;

                    NodeId nodeId = ExpandedNodeId.ToNodeId(reference.NodeId, m_browser.Session.NamespaceUris);

                    INode node = m_browser.Session.ReadNode(nodeId);

                    byte accessLevel   = 0;
                    byte eventNotifier = 0;
                    bool executable    = false;

                    VariableNode variableNode = node as VariableNode;

                    if (variableNode != null)
                    {
                        accessLevel = variableNode.UserAccessLevel;
                    }

                    ObjectNode objectNode = node as ObjectNode;

                    if (objectNode != null)
                    {
                        eventNotifier = objectNode.EventNotifier;
                    }

                    ViewNode viewNode = node as ViewNode;

                    if (viewNode != null)
                    {
                        eventNotifier = viewNode.EventNotifier;
                    }

                    MethodNode methodNode = node as MethodNode;

                    if (methodNode != null)
                    {
                        executable = methodNode.UserExecutable;
                    }

                    ReadMI.Visible          = false;
                    HistoryReadMI.Visible   = false;
                    WriteMI.Visible         = false;
                    HistoryUpdateMI.Visible = false;
                    EncodingsMI.Visible     = false;
                    SubscribeMI.Visible     = false;
                    CallMI.Visible          = false;

                    if (accessLevel != 0)
                    {
                        ReadMI.Visible          = true;
                        HistoryReadMI.Visible   = true;
                        WriteMI.Visible         = true;
                        HistoryUpdateMI.Visible = true;
                        EncodingsMI.Visible     = true;
                        SubscribeMI.Visible     = m_SessionTreeCtrl != null;

                        if ((accessLevel & (byte)AccessLevels.CurrentRead) != 0)
                        {
                            ReadMI.Enabled         = true;
                            EncodingsMI.Enabled    = true;
                            SubscribeMI.Enabled    = true;
                            SubscribeNewMI.Enabled = true;
                        }

                        if ((accessLevel & (byte)AccessLevels.CurrentWrite) != 0)
                        {
                            WriteMI.Enabled     = true;
                            EncodingsMI.Enabled = true;
                        }

                        if ((accessLevel & (byte)AccessLevels.HistoryRead) != 0)
                        {
                            HistoryReadMI.Enabled = true;
                        }

                        if ((accessLevel & (byte)AccessLevels.HistoryWrite) != 0)
                        {
                            HistoryUpdateMI.Enabled = true;
                        }
                    }

                    if (eventNotifier != 0)
                    {
                        HistoryReadMI.Visible   = true;
                        HistoryUpdateMI.Visible = true;
                        SubscribeMI.Visible     = true;

                        if ((eventNotifier & (byte)EventNotifiers.HistoryRead) != 0)
                        {
                            HistoryReadMI.Enabled = true;
                        }

                        if ((eventNotifier & (byte)EventNotifiers.HistoryWrite) != 0)
                        {
                            HistoryUpdateMI.Enabled = true;
                        }

                        SubscribeMI.Enabled    = (eventNotifier & (byte)EventNotifiers.SubscribeToEvents) != 0;
                        SubscribeNewMI.Enabled = SubscribeMI.Enabled;
                    }

                    if (methodNode != null)
                    {
                        CallMI.Visible = true;
                        CallMI.Enabled = executable;
                    }

                    if (variableNode != null && EncodingsMI.Enabled)
                    {
                        ReferenceDescriptionCollection encodings = m_browser.Session.ReadAvailableEncodings(variableNode.NodeId);

                        if (encodings.Count == 0)
                        {
                            EncodingsMI.Visible = false;
                        }
                    }

                    if (SubscribeMI.Enabled)
                    {
                        while (SubscribeMI.DropDown.Items.Count > 1)
                        {
                            SubscribeMI.DropDown.Items.RemoveAt(SubscribeMI.DropDown.Items.Count - 1);
                        }

                        foreach (Subscription subscription in m_browser.Session.Subscriptions)
                        {
                            if (subscription.Created)
                            {
                                ToolStripItem item = SubscribeMI.DropDown.Items.Add(subscription.DisplayName);
                                item.Click += new EventHandler(Subscription_Click);
                                item.Tag    = subscription;
                            }
                        }
                    }
                }
            }
        }
Пример #56
0
 public bool hasProperty(INode property)
 {
     return(_model.GetTriplesWithSubjectPredicate(_source, property).Any());
 }
        private (double weight, NodeDirection?Direction) ApplyWeightAndDirection(AStarNode nodeOne, INode nodeTwo)
        {
            var x1 = nodeOne.Row;
            var y1 = nodeOne.Col;
            var x2 = nodeTwo.Row;
            var y2 = nodeTwo.Col;

            if (x2 < x1 &&
                y1 == y2)
            {
                switch (nodeOne.Direction)
                {
                case NodeDirection.Up:
                    return(1, NodeDirection.Up);

                case NodeDirection.Right:
                    return(2, NodeDirection.Up);

                case NodeDirection.Left:
                    return(2, NodeDirection.Up);

                case NodeDirection.Down:
                    return(3, NodeDirection.Up);
                }
            }
            else if (x2 > x1 &&
                     y1 == y2)
            {
                switch (nodeOne.Direction)
                {
                case NodeDirection.Up:
                    return(3, NodeDirection.Down);

                case NodeDirection.Right:
                    return(2, NodeDirection.Down);

                case NodeDirection.Left:
                    return(2, NodeDirection.Down);

                case NodeDirection.Down:
                    return(1, NodeDirection.Down);
                }
            }

            if (y2 < y1 &&
                x1 == x2)
            {
                switch (nodeOne.Direction)
                {
                case NodeDirection.Up:
                    return(2, NodeDirection.Left);

                case NodeDirection.Right:
                    return(3, NodeDirection.Left);

                case NodeDirection.Left:
                    return(1, NodeDirection.Left);

                case NodeDirection.Down:
                    return(2, NodeDirection.Left);
                }
            }
            else if (y2 > y1 &&
                     x1 == x2)
            {
                switch (nodeOne.Direction)
                {
                case NodeDirection.Up:
                    return(2, NodeDirection.Right);

                case NodeDirection.Right:
                    return(1, NodeDirection.Right);

                case NodeDirection.Left:
                    return(3, NodeDirection.Right);

                case NodeDirection.Down:
                    return(2, NodeDirection.Right);
                }
            }

            return(default);
Пример #58
0
 public IEnumerable <IResource> getObjects(INode property)
 {
     return(_model.GetTriplesWithSubjectPredicate(this, property).Select(t => Resource.Get(t.Object, _model)));
 }
Пример #59
0
 public Comment(INode parent, string content)
     : base(parent)
 {
     this.content = content;
 }
            protected override void VisitUnknownNode(INode node)
            {
                Range range = node.Range;

                throw CreateRewriteError(_module, node.Location.Start, $"'{_module.Content.Substring(range.Start, range.End - range.Start)}' is not supported currently.");
            }