Ejemplo n.º 1
0
        public void CurrentStep()
        {
            var pipeline = new CompilerPipeline();

            var step1 = new ActionStep(delegate {});

            pipeline.Add(step1);

            ActionStep step2 = null;

            step2 = new ActionStep(() => Assert.AreSame(step2, pipeline.CurrentStep));
            pipeline.Add(step2);

            var currentSteps = new Boo.Lang.List();

            pipeline.Before     += (sender, args) => currentSteps.Add(pipeline.CurrentStep);
            pipeline.BeforeStep += (sender, args) => currentSteps.Add(pipeline.CurrentStep);
            pipeline.AfterStep  += (sender, args) => currentSteps.Add(pipeline.CurrentStep);
            pipeline.After      += (sender, args) => currentSteps.Add(pipeline.CurrentStep);

            pipeline.Run(new CompilerContext());

            Assert.AreEqual(
                new object[] { null, step1, step1, step2, step2, null },
                currentSteps.ToArray());
        }
    public static string CreateUXMLTemplate(string folder)
    {
        UxmlSchemaGenerator.UpdateSchemaFiles();

        string[] pathComponents         = folder.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
        Boo.Lang.List <string> backDots = new Boo.Lang.List <string>();
        foreach (var s in pathComponents)
        {
            if (s == ".")
            {
                continue;
            }
            if (s == ".." && backDots.Count > 0)
            {
                backDots.RemoveAt(backDots.Count - 1);
            }
            else
            {
                backDots.Add("..");
            }
        }
        backDots.Add(UxmlSchemaGenerator.k_SchemaFolder);
        string schemaDirectory = string.Join("/", backDots.ToArray());

        string xmlnsList          = String.Empty;
        string schemaLocationList = String.Empty;
        Dictionary <string, string> namespacePrefix = UxmlSchemaGenerator.GetNamespacePrefixDictionary();

        foreach (var prefix in namespacePrefix)
        {
            if (prefix.Key == String.Empty)
            {
                continue;
            }

            if (prefix.Value != String.Empty)
            {
                xmlnsList += "    xmlns:" + prefix.Value + "=\"" + prefix.Key + "\"\n";
            }
            schemaLocationList += "                        " + prefix.Key + " " + schemaDirectory + "/" +
                                  UxmlSchemaGenerator.GetFileNameForNamespace(prefix.Key) + "\n";
        }

        // The noNamespaceSchemaLocation attribute should be sufficient to reference all namespaces
        // but Rider does not support it very well, so we add schemaLocation to make it happy.
        string uxmlTemplate = String.Format(@"<?xml version=""1.0"" encoding=""utf-8""?>
<engine:{0}
xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""
{1}
xsi:noNamespaceSchemaLocation=""{2}/UIElements.xsd""
xsi:schemaLocation=""
{3}""
>
    <engine:Label text=""Hello World! From UXML"" />
</engine:{0}>", UXMLImporterImpl.k_RootNode, xmlnsList, schemaDirectory, schemaLocationList);

        return(uxmlTemplate);
    }
Ejemplo n.º 3
0
		public void EventSequence()
		{
			var calls = new List<string>();
			var pipeline = new CompilerPipeline();
			pipeline.Before += delegate { calls.Add("before"); };
			pipeline.BeforeStep += delegate { calls.Add("before step"); };
			pipeline.Add(new ActionStep(() => calls.Add("step")));
			pipeline.AfterStep += delegate { calls.Add("after step"); };
			pipeline.After += delegate { calls.Add("after"); };
			pipeline.Run(new CompilerContext());
			Assert.AreEqual(
				new string[] {"before", "before step", "step", "after step", "after"},
				calls.ToArray());
		}
Ejemplo n.º 4
0
        private void BlockTag(string tag, IDictionary attributes, ICallable block)
        {
            Output.Write("<{0}", tag);

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

            if (null != attributes)
            {
                foreach (DictionaryEntry entry in attributes)
                {
                    attributeValues.Add(string.Format("{0}=\"{1}\"", entry.Key, entry.Value));
                }
            }

            if (0 != attributeValues.Count)
            {
                Output.Write(" ");
                Output.Write(string.Join(" ", attributeValues.ToArray()));
            }

            Output.Write(">");
            if(block!=null)
            {
                block.Call(null);
            }
            Output.Write("</{0}>", tag);
        }
Ejemplo n.º 5
0
		public void CurrentStep()
		{
			var pipeline = new CompilerPipeline();

			var step1 = new ActionStep(delegate {});
			pipeline.Add(step1);

			ActionStep step2 = null;
			step2 = new ActionStep(() => Assert.AreSame(step2, pipeline.CurrentStep));
			pipeline.Add(step2);

			var currentSteps = new Boo.Lang.List();
			pipeline.Before += (sender, args) => currentSteps.Add(pipeline.CurrentStep);
			pipeline.BeforeStep += (sender, args) => currentSteps.Add(pipeline.CurrentStep);
			pipeline.AfterStep += (sender, args) => currentSteps.Add(pipeline.CurrentStep);
			pipeline.After += (sender, args) => currentSteps.Add(pipeline.CurrentStep);

			pipeline.Run(new CompilerContext());

			Assert.AreEqual(
				new object[] { null, step1, step1, step2, step2, null },
				currentSteps.ToArray());
		}
Ejemplo n.º 6
0
    private void OnClickRemoveNode(Node node)
    {
        if (_connections != null)
        {
            Boo.Lang.List <Connection> connectionsToRemove = new Boo.Lang.List <Connection>();

            for (int i = 0; i < _connections.Count; i++)
            {
                if (_connections[i].inPoint == node.inPoint || _connections[i].outPoint == node.outPoint)
                {
                    connectionsToRemove.Add(_connections[i]);
                }
            }

            for (int i = 0; i < connectionsToRemove.Count; i++)
            {
                _connections.Remove(connectionsToRemove[i]);
            }

            connectionsToRemove = null;
        }

        _nodes.Remove(node);
    }
Ejemplo n.º 7
0
        public static Array array(Type elementType, IEnumerable enumerable)
        {
            if (null == enumerable)
            {
                throw new ArgumentNullException("enumerable");
            }
            if (null == elementType)
            {
                throw new ArgumentNullException("elementType");
            }

            // future optimization, check EnumeratorItemType of enumerable
            // and get the fast path whenever possible
            List l = null;
            if (RuntimeServices.IsPromotableNumeric(Type.GetTypeCode(elementType)))
            {
                l = new List();
                foreach (object item in enumerable)
                {
                    object value = RuntimeServices.CheckNumericPromotion(item).ToType(elementType, null);
                    l.Add(value);
                }
            }
            else
            {
                l = new List(enumerable);
            }
            return l.ToArray(elementType);
        }
Ejemplo n.º 8
0
		public void ExecutionOrder()
		{
			var order = new List<string>();
			var p1 = new ActionStep(() => order.Add("p1"));
			var p2 = new ActionStep(() => order.Add("p2"));

			var pipeline = new CompilerPipeline { p1, p2 };
			pipeline.Run(new CompilerContext());

			Assert.AreEqual(new[] { "p1", "p2" }, order.ToArray());
		}
Ejemplo n.º 9
0
 public void TestEventSequence()
 {
     List calls = new List();
     _pipeline.Before += delegate { calls.Add("before"); };
     _pipeline.BeforeStep += delegate { calls.Add("before step"); };
     _pipeline.Add(new ActionStep(delegate { calls.Add("step"); }));
     _pipeline.AfterStep += delegate { calls.Add("after step"); };
     _pipeline.After += delegate { calls.Add("after"); };
     _pipeline.Run(new CompilerContext());
     Assert.AreEqual(
         new List(new string[] {"before", "before step", "step", "after step", "after"}),
         calls);
 }
Ejemplo n.º 10
0
 void InnerCollect(List target, Predicate condition)
 {
     for (int i=0; i<_count; ++i)
     {
         object item = _items[i];
         if (condition(item))
         {
             target.Add(item);
         }
     }
 }
Ejemplo n.º 11
0
 public Expression array_initializer()
 {
     Expression expression = null;
     List<Expression> dimensions = new List<Expression>(1);
     try
     {
         TypeReference elementType = this.simple_type_reference();
         this.match(0x44);
         Expression item = this.sum();
         if (base.inputState.guessing == 0)
         {
             dimensions.Add(item);
         }
         while (this.LA(1) == 0x43)
         {
             this.match(0x43);
             item = this.sum();
             if (base.inputState.guessing == 0)
             {
                 dimensions.Add(item);
             }
         }
         this.match(0x45);
         if (base.inputState.guessing == 0)
         {
             expression = CodeFactory.NewArrayInitializer(elementType.get_LexicalInfo(), elementType, dimensions);
         }
     }
     catch (RecognitionException exception)
     {
         if (base.inputState.guessing != 0)
         {
             throw;
         }
         this.reportError(exception);
         this.recover(exception, tokenSet_20_);
         return expression;
     }
     return expression;
 }