public void TestFixtureSetUp()
 {
     _root = new Root(TestConfig.RepositoryPath, TestConfig.ModuleName, TestConfig.CVSHost, TestConfig.CVSPort, TestConfig.Username, TestConfig.Password);
      _root.WorkingDirectory = TestConfig.WorkingDirectory;
      _mocks = new MockRepository();
      _connection = _mocks.Stub<IConnection>();
 }
Exemplo n.º 2
0
		public BindingContext(UIView view, string title, Theme currentTheme)
		{
			if (view == null)
				throw new ArgumentNullException("view");
			
			var parser = new ViewParser();

			parser.Parse(view, title, currentTheme);
			Root = parser.Root;

			var viewContext = view as IBindingContext;
			if (viewContext != null)
			{
				viewContext.BindingContext = this;
				var dataContext = view as IDataContext;
				if (dataContext != null)
				{
					var vmContext = dataContext.DataContext as IBindingContext;
					if (vmContext != null)
					{
						vmContext.BindingContext = this;
					}
				}
			}
		}
Exemplo n.º 3
0
		public BindingContext(object view, string title, Theme currentTheme)
		{
			if (view == null)
				throw new ArgumentNullException("view");

			BuildElementPropertyMap();
			Root = new RootElement(title);
			Root.ViewBinding.DataContext = view;
			var themeable = Root as IThemeable;
			if (themeable != null)
				themeable.Theme = Theme.CreateTheme(currentTheme);
			
			Populate(view, Root);

			var viewContext = view as IBindingContext;
			if (viewContext != null)
			{
				viewContext.BindingContext = this;
				var dataContext = view as IDataContext;
				if (dataContext != null)
				{
					var vmContext = dataContext.DataContext as IBindingContext;
					if (vmContext != null)
					{
						vmContext.BindingContext = this;
					}
				}
			}
		}
 public void SetUp()
 {
     _root = new Root(TestConfig.RepositoryPath, TestConfig.ModuleName, TestConfig.CVSHost, TestConfig.CVSPort, TestConfig.Username, TestConfig.Password);
      _root.WorkingDirectory = TestConfig.WorkingDirectory;
      _root.Module = TestConfig.ModuleName;
      _connection = new PServerConnection();
 }
 private static IEnumerable<IClass> GetRDomClasses(IRoot root)
 {
     return root.RootClasses
                 .Where(x => x.BaseType != null
     && ((x.BaseType.Name == "RDomBaseType" && x.BaseType.TypeArguments.Count() == 1)
           || (x.BaseType.Name.StartsWith("RDomBase") && x.BaseType.TypeArguments.Count() == 2)));
 }
Exemplo n.º 6
0
        public void Inject()
        {
            root = root ?? SceneUtility.FindComponent<IRoot>(CachedGameObject.scene);

            if (root == null || root.Container == null)
                return;

            root.Container.Injector.Inject(this);
            injected = true;
        }
Exemplo n.º 7
0
 private IRoot ExecuteAllRootFilter(IRoot root)
 {
     foreach (var rootexcuter in RootWorkunit())
     {
         rootexcuter.Workunit = root;
         ((IExecuteable)rootexcuter).Execute();
         root = rootexcuter.Workunit;
     }
     return root;
 }
Exemplo n.º 8
0
		public static IRoot CreateRootedView(IRoot root)
		{
			IRoot newRoot = null;

			if (root.ViewBinding != null)
			{
				newRoot = RootBuilder[root.ViewBinding.DataContextCode](root);
			}

			return newRoot;
		}
 /// <summary>
 /// Initializes a new instance of the <see cref="AuthRequestBase"/> class.
 /// </summary>
 /// <param name="root">The CVS root.</param>
 /// <param name="type">The auth request type.</param>
 protected AuthRequestBase(IRoot root, RequestType type)
 {
     _root = root;
      Lines = new string[5];
      string requestName = RequestHelper.RequestNames[(int) type];
      Lines[0] = string.Format("BEGIN {0} REQUEST", requestName);
      Lines[1] = _root.Repository;
      Lines[2] = _root.Username;
      Lines[3] = _root.Password;
      Lines[4] = string.Format("END {0} REQUEST", requestName);
 }
Exemplo n.º 10
0
		private List<ISection> CreateSectionList(object dataContext, IRoot root)
		{
			ISection lastSection = new Section() { Order = -1, Parent = root as Element };

			var sectionList = new List<ISection>() { lastSection };
			Element newElement = null;

			var members = GetMembers(dataContext);

			foreach (var member in members)
			{
				var skipAttribute = member.GetCustomAttribute<SkipAttribute>(true);
				if(skipAttribute != null) continue;

				var inline = member.GetCustomAttribute<InlineAttribute>() != null;
				var isList = member.GetCustomAttribute<ListAttribute>() != null;
				var sectionAttribute = member.GetCustomAttribute<SectionAttribute>();

				if (sectionAttribute != null)
				{
					lastSection = new Section(sectionAttribute.Caption, sectionAttribute.Footer) { Order = sectionAttribute.Order };
					lastSection.Parent = root as Element;
					sectionList.Add(lastSection);
				}
				
				newElement = GetElementForMember(dataContext, member);

				if(newElement != null)
				{
					if ((inline || isList) && newElement is IRoot)
					{
						foreach(var element in ((IRoot)newElement).Sections[0].Elements)
							lastSection.Add(element);
	
						root.Group = ((IRoot)newElement).Group;
					}
					else
					{
						lastSection.Add(newElement);
					}
				}
			}

			foreach (var section in sectionList)
			{
				var orderedList = section.Elements.OrderBy(e=>e.Order).ToList();
				section.Elements = orderedList;
			}

			var orderedSections = sectionList.Where(s=>s.Elements.Count > 0).OrderBy(section=>section.Order).ToList();
			return orderedSections;
		}
Exemplo n.º 11
0
		public BindingContext(object dataContext, string title)
		{
			if (dataContext == null)
				throw new ArgumentNullException("dataContext");
			
			var view = dataContext as IView;
			if (view != null && view.Root != null && view.Root.Count > 0)
				Root = view.Root;
			else
			{
				BuildElementPropertyMap();
				Root = new RootElement<int>(title);
				Populate(dataContext, Root);
			}
		}
Exemplo n.º 12
0
        public void Execute(IRoot Root)
        {
            // erst die root filter
            Root = ExecuteAllRootFilter(Root);

            // dann die subroot filter
            for(int i = 0; i< Root.SubRoots.Count; i++)
            {
                Root.SubRoots[i] = ExecuteAllSubRootFilter(Root.SubRoots[i]);

                // dann die leaf filter
                for (int j = 0; j < Root.SubRoots[i].Leafs.Count; j++)
                {
                    Root.SubRoots[i].Leafs[j] = ExecuteAllLeafFilter(Root.SubRoots[i].Leafs[j]);
                }
            }
        }
Exemplo n.º 13
0
		private void Populate(object view, IRoot root)
		{
			var enableSearchAttribute = view.GetType().GetCustomAttribute<EnableSearchAttribute>();
			var searchbar = root as ISearchBar;
			if (enableSearchAttribute != null && searchbar != null)
			{
				searchbar.AutoHideSearch = enableSearchAttribute.AutoHide;
				searchbar.SearchPlaceholder = enableSearchAttribute.Placeholder;
				searchbar.IncrementalSearch = enableSearchAttribute.IncrementalSearch;
				searchbar.EnableSearch = true;
			}

			root.Add(CreateSectionList(view, root));
			
			root.ToolbarButtons = CheckForToolbarItems(view);
			root.NavbarButtons = CheckForNavbarItems(view);
		}
Exemplo n.º 14
0
		public void Parse(UIView view, string caption, Theme theme)
		{
			var vw = view as IView;
			if (vw != null)
			{
				var captionAttribute = view.GetType().GetCustomAttribute<CaptionAttribute>();
				if (captionAttribute != null)
					caption = captionAttribute.Caption;
			}

			Root = new RootElement(caption) { Opaque = false };
			Root.DataContext = view;

			var dataContext = view as IDataContext;
			if (dataContext != null)
				Root.DataContext = dataContext.DataContext;

			var themeable = Root as IThemeable;
			if (themeable != null)
				themeable.Theme = Theme.CreateTheme(theme);
			
			var searchbarAttribute = view.GetType().GetCustomAttribute<SearchbarAttribute>();
			var searchbar = Root as ISearchBar;
			if (searchbarAttribute != null && searchbar != null)
			{
				searchbar.SearchPlaceholder = searchbarAttribute.Placeholder;
				searchbar.IncrementalSearch = searchbarAttribute.IncrementalSearch;
				searchbar.EnableSearch = true;
				searchbar.IsSearchbarHidden = false;
			}
			
			var sectionList = CreateSectionList(view, Root);
			sectionList.ForEach((section)=>section.BeginInit());
			Root.Add(sectionList);
			
			Root.ToolbarButtons = CheckForToolbarItems(view);
			Root.NavbarButtons = CheckForNavbarItems(view);

			var notifyDataContextChanged = view as INotifyDataContextChanged;
			if (notifyDataContextChanged != null)
			{
				notifyDataContextChanged.DataContextChanged += HandleNotifyDataContextChangedDataContextChanged;
			}
		}
Exemplo n.º 15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CommandBase"/> class.
        /// </summary>
        /// <param name="root">The CVS root.</param>
        /// <param name="connection">The connection.</param>
        protected CommandBase(IRoot root, IConnection connection)
        {
            BasicConfigurator.Configure();
             _logger = LogManager.GetLogger(typeof(CommandBase));
             _connection = connection;
             Responses = new List<IResponse>();
             UserMessages = new List<string>();

             Root = root;
             Requests = new List<IRequest>();
             RequiredRequests = new List<IRequest>();
             Items = new List<ICommandItem>();

             // add auth and other required requests for most commands
             RequiredRequests.Add(new AuthRequest(root));
             RequiredRequests.Add(new UseUnchangedRequest());
             RequiredRequests.Add(new ValidResponsesRequest(RequestHelper.ValidResponses));
             RequiredRequests.Add(new ValidRequestsRequest());
             ValidRequestTypes = new List<RequestType>();
        }
Exemplo n.º 16
0
        private IEnumerable<IteratorContainer> HandleRoot(IRoot root)
        {
            var subroots = root.SubRoots;

            var container = new IteratorContainer();

            container.SetData(root);
            container.Stop = true;
            foreach (var item in subroots)
            {
                container.SetData(item);
                container.Stop = true;
                foreach (var leaf in item.Leafs)
                {
                    container.SetData(leaf);
                    yield return container;
                    container.Stop = false;
                }
            }
        }
Exemplo n.º 17
0
        /// <summary></summary>
        protected virtual bool CheckLibraryNames(IRoot root)
        {
            IList <ILibrary> ValidatedLibraryList = new List <ILibrary>();
            bool             IsLibraryNamesValid  = true;

            // Basic name checks.
            foreach (ILibrary Library in root.LibraryList)
            {
                IsLibraryNamesValid &= Library.CheckLibraryNames(LibraryTable, ValidatedLibraryList, ErrorList);
            }

            foreach (KeyValuePair <string, ISealableDictionary <string, ILibrary> > Entry in LibraryTable)
            {
                string ValidLibraryName = Entry.Key;

                // List all libraries with the same name and no source.
                List <ILibrary> DuplicateLibraryList = new List <ILibrary>();
                foreach (ILibrary Item in ValidatedLibraryList)
                {
                    if (Item.ValidLibraryName == ValidLibraryName && !Item.FromIdentifier.IsAssigned)
                    {
                        DuplicateLibraryList.Add(Item);
                    }
                }

                // If more than one, report an error for each of them.
                if (DuplicateLibraryList.Count > 1)
                {
                    IsLibraryNamesValid = false;

                    foreach (ILibrary Item in DuplicateLibraryList)
                    {
                        ErrorList.AddError(new ErrorSourceRequired((IName)Item.EntityName));
                    }
                }
            }

            Debug.Assert(IsLibraryNamesValid || !ErrorList.IsEmpty);
            return(IsLibraryNamesValid);
        }
Exemplo n.º 18
0
        /// <summary></summary>
        protected virtual bool Resolve(IRoot root, IRuleTemplateList ruleTemplateList, string passName)
        {
            BuildInferenceSourceList Context = new BuildInferenceSourceList(ruleTemplateList);
            IWalkCallbacks <BuildInferenceSourceList> Callbacks = new WalkCallbacks <BuildInferenceSourceList>()
            {
                HandlerNode = ListAllSources, IsRecursive = true, BlockSubstitution = CreateBlockSubstitution()
            };
            IList <IClass> ClassList = root.ClassList;

            foreach (IClass Class in ClassList)
            {
                NodeTreeWalk.Walk <BuildInferenceSourceList>(Class, Callbacks, Context);
            }

            IList <ISource> SourceList = Context.SourceList;
            InferenceEngine Engine     = new InferenceEngine(ruleTemplateList, SourceList, ClassList, true, InferenceRetries);

            bool Success = Engine.Solve(ErrorList, passName);

            Debug.Assert(Success || !ErrorList.IsEmpty);
            return(Success);
        }
Exemplo n.º 19
0
        public void Write_all_text_writes_root_to_new_directory()
        {
            const string dirName  = "TempTestDir";
            string       fileName = Path.Combine(dirName, "temp.cs");

            if (Directory.Exists(dirName))
            {
                Directory.Delete(dirName, true);
            }
            var   csharpCode = @"
                        using System.Diagnostics.Tracing;
                        namespace Namespace1
                        { }";
            IRoot root       = RDom.CSharp.Load(csharpCode);

            Assert.IsNotNull(root);
            UpdateUtilities.WriteToFile(fileName, root);
            File.Exists(fileName);
            var actual = File.ReadAllText(fileName);

            Assert.AreEqual(csharpCode, actual);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Class constructor from an available parentNode and directory model
        /// to recurse down on a given structure.
        /// </summary>
        /// <param name="dir"></param>
        /// <param name="parentNode"></param>
        internal BreadcrumbTreeItemViewModel(IDirectoryBrowser dir,
                                             BreadcrumbTreeItemViewModel parentNode,
                                             IRoot <IDirectoryBrowser> root
                                             )
        {
            Logger.InfoFormat("FullName '{0}'", (dir != null ? dir.FullName : "(null)"));

            _Root = root;
            _dir  = dir;

            // If parentNode == null => Parent of Root is null
            _rootNode   = parentNode == null ? this : parentNode._rootNode;
            _parentNode = parentNode;

            Header = (dir != null ? _dir.Label : string.Empty);

            Func <bool, object, Task <IEnumerable <BreadcrumbTreeItemViewModel> > > loadAsyncFunc = (isLoaded, parameter) => Task.Run(() =>
            {
                try
                {
                    var subItemsList = Browser.GetChildItems(_dir.FullName, null, SubItemFilter.NameOnly, true);

                    // FullName has preference for directory file system path over SpecialId
                    // (if an item has both)
                    // -> this is useful here to no relist SpecialItems below Desktop or other special items
                    return(subItemsList.Select(d => new BreadcrumbTreeItemViewModel(d, this, _Root)));
                }
                catch (Exception exp)
                {
                    Logger.Error(exp);
                    return(new List <BreadcrumbTreeItemViewModel>());
                }
            });

            this.Entries   = new BreadcrumbTreeItemHelperViewModel <BreadcrumbTreeItemViewModel>(loadAsyncFunc);
            this.Selection = new TreeSelectorViewModel <BreadcrumbTreeItemViewModel, IDirectoryBrowser>
                                 (_dir, this, this.Entries);
        }
Exemplo n.º 21
0
        /// <summary></summary>
        protected virtual bool CheckLibrariesConsistency(IRoot root)
        {
            List <ILibrary> ResolvedLibraryList   = new List <ILibrary>();
            List <ILibrary> UnresolvedLibraryList = new List <ILibrary>(root.LibraryList);

            bool Success  = true;
            bool Continue = true;

            while (UnresolvedLibraryList.Count > 0 && Success && Continue)
            {
                // Continue while there is a library to process.
                Continue = false;

                foreach (ILibrary Library in UnresolvedLibraryList)
                {
                    Success &= Library.Resolve(LibraryTable, ResolvedLibraryList, ref Continue, ErrorList);
                }

                MoveResolvedLibraries(UnresolvedLibraryList, ResolvedLibraryList, ref Continue);
            }

            // If we're stuck at processing remaining libraries, it's because they are referencing each other in a cycle.
            if (UnresolvedLibraryList.Count > 0 && Success)
            {
                Success = false;

                IList <string> NameList = new List <string>();
                foreach (ILibrary Library in UnresolvedLibraryList)
                {
                    NameList.Add(Library.ValidLibraryName);
                }

                ErrorList.AddError(new ErrorCyclicDependency(NameList, "Library"));
            }

            Debug.Assert(Success || !ErrorList.IsEmpty);
            return(Success);
        }
Exemplo n.º 22
0
        /// <summary>
        /// Internally handles the Setup process.
        /// </summary>
        private void SetupInternal <T>(T runner, TestOptions testOptions)
            where T : class
        {
            this.testOptions = testOptions;

            if (testOptions.Dependency == null)
            {
                testOptions.Dependency = new DependencyContainer(true);
            }

            // Initialize camera
            if (testOptions.UseCamera)
            {
                Camera camera = new GameObject("_Camera").AddComponent <Camera>();
                camera.tag = "MainCamera";
                camera.gameObject.AddComponent <AudioListener>();
                camera.clearFlags      = CameraClearFlags.SolidColor;
                camera.backgroundColor = Color.black;
            }

            // Initialize default root.
            if (testOptions.DefaultRoot != null)
            {
                IRoot root = UguiRoot.Create(testOptions.Dependency);
                if (Camera.main != null)
                {
                    root.SetCameraRender(Camera.main);
                }
                else
                {
                    root.SetOverlayRender();
                }
                root.BaseResolution = testOptions.DefaultRoot.BaseResolution;
            }

            // Inititialize
            testOptions.Dependency.Inject(runner);
        }
        private bool ShouldRun(IRoot root, string attributeIdentifier)
        {
            if (string.IsNullOrWhiteSpace(attributeIdentifier))
            {
                return(true);
            }
            var attributeUsed = root.RootClasses
                                .Any(x => x.Attributes
                                     .Any(y => y.Name == attributeIdentifier));

            //var classes = (from x in root.RootClasses
            //               from y in x.Attributes
            //               where y.Name == attributeIdentifier
            //               select true);
            if (attributeUsed)
            {
                return(true);
            }
            var hasNamedBase = root.RootClasses
                               .Any(x => x.BaseType != null && x.BaseType.Name == attributeIdentifier + "Base");

            return(hasNamedBase);
        }
        private void ProcessGlobalReplicates(IRoot root, ReplicationContext context)
        {
            List <ICompiledReplicate> ReplicateList = new List <ICompiledReplicate>();

            foreach (IGlobalReplicate ReplicateItem in root.Replicates)
            {
                Debug.Assert(ReplicateItem.PatternList.Count == 0);

                foreach (IPattern PatternItem in ReplicateItem.Patterns)
                {
                    ReplicateItem.PatternList.Add(PatternItem);
                }

                ReplicateList.Add(ReplicateItem);
            }

            CheckReplicates(ReplicateList, context);

            Debug.Assert(context.GlobalReplicateTable.Count == 0);
            foreach (KeyValuePair <string, List <string> > Entry in context.ReplicateTable)
            {
                context.GlobalReplicateTable.Add(Entry.Key, Entry.Value);
            }
        }
 /// <summary>
 ///     Creates a new DialogViewController from a IRoot and sets the push status
 /// </summary>
 /// <param name="_Root">
 /// The <see cref="IRoot"/> containing the information to render.
 /// </param>
 /// <param name="_Pushing">
 /// A <see cref="System.Boolean"/> describing whether this is being pushed
 /// (NavigationControllers) or not.   If _Pushing is true, then the back button
 /// will be shown, allowing the user to go back to the previous controller
 /// </param>
 public DialogViewController(IRoot root, bool pushing) : base(UITableViewStyle.Grouped)
 {
     _Pushing = pushing;
     PrepareRoot(root);
 }
 public DialogViewController(IRoot root) : base(UITableViewStyle.Grouped)
 {
     PrepareRoot(root);
 }
Exemplo n.º 27
0
		private static IRoot CreateObjectRoot(IRoot root)
		{
			IRoot newRoot = null;
			UIView view = null;
			object context = root.DataContext;

			try
			{				
				if (root.ViewBinding.ViewType != null)
				{
					view = Activator.CreateInstance(root.ViewBinding.ViewType) as UIView;
				}

				var dataContext = view as IDataContext;
				if (dataContext != null)
				{
					dataContext.DataContext = context;

					var lifetime = context as ISupportInitialize;
					if (lifetime != null)
						lifetime.BeginInit();
					
					lifetime = dataContext as ISupportInitialize;
					if (lifetime != null)
						lifetime.BeginInit();
				}
				
				var bindingContext = new BindingContext(view, root.Caption, root.Theme);

				newRoot = (IRoot)bindingContext.Root;
				newRoot.ViewBinding = root.ViewBinding;
				newRoot.ViewBinding.View = view;
			}
			catch(MissingMethodException)
			{
			}
			
			return newRoot;
		}
Exemplo n.º 28
0
        private List <ISection> CreateSectionList(object dataContext, IRoot root)
        {
            ISection lastSection = new Section()
            {
                Order = -1, Parent = root as Element
            };

            var sectionList = new List <ISection>()
            {
                lastSection
            };
            Element newElement = null;

            var members = GetMembers(dataContext);

            foreach (var member in members)
            {
                var skipAttribute = member.GetCustomAttribute <SkipAttribute>(true);
                if (skipAttribute != null)
                {
                    continue;
                }

                var inline           = member.GetCustomAttribute <InlineAttribute>() != null;
                var isList           = member.GetCustomAttribute <ListAttribute>() != null;
                var sectionAttribute = member.GetCustomAttribute <SectionAttribute>();

                if (sectionAttribute != null)
                {
                    lastSection = new Section(sectionAttribute.Caption, sectionAttribute.Footer)
                    {
                        Order = sectionAttribute.Order
                    };
                    lastSection.Parent = root as Element;
                    sectionList.Add(lastSection);
                }

                newElement = GetElementForMember(dataContext, member);

                if (newElement != null)
                {
                    if ((inline || isList) && newElement is IRoot)
                    {
                        foreach (var element in ((IRoot)newElement).Sections[0].Elements)
                        {
                            lastSection.Add(element);
                        }

                        root.Group = ((IRoot)newElement).Group;
                    }
                    else
                    {
                        lastSection.Add(newElement);
                    }
                }
            }

            foreach (var section in sectionList)
            {
                var orderedList = section.Elements.OrderBy(e => e.Order).ToList();
                section.Elements = orderedList;
            }

            var orderedSections = sectionList.Where(s => s.Elements.Count > 0).OrderBy(section => section.Order).ToList();

            return(orderedSections);
        }
Exemplo n.º 29
0
 //-----------------------------------------------------------------------------------------------------------------------
 //-----------------------------------------------------------------------------------------------------------------------
 //-----------------------------------------------------------------------------------------------------------------------
 public void WorkUnit(IRoot workunit)
 {
     this.Root = workunit;
 }
		public DialogViewController(UITableViewStyle style, IRoot root, bool pushing) : base(style)
		{
			_Pushing = pushing;
			Style = style;
			PrepareRoot(root);
		}
		protected void PrepareRoot(IRoot root)
		{
			Root = root;
			if (Root != null)
				Root.Prepare();
		}
Exemplo n.º 32
0
        public App(IApplicationQuitter applicationQuitter, WindowNavigation windowNavigation, IRoot root,
                   IPauseAdapter pauseAdapter, ILogger logger, GameStrategyFactory gameFactory, IDataProvider <Game.Entities.Game> gameDataProvider)
        {
            this.applicationQuitter = applicationQuitter;
            this.windowNavigation   = windowNavigation;
            this.root                = root;
            this.pauseAdapter        = pauseAdapter;
            this.logger              = logger;
            this.gameStrategyFactory = gameFactory;
            this.gameDataProvider    = gameDataProvider;

            applicationQuitter.OnQuit += ApplicationQuitter_OnQuit;
            pauseAdapter.OnPause      += PauseAdapter_OnPause;
            root.OnInitialized        += Root_OnInitialized;
        }
Exemplo n.º 33
0
        static Cache()
        {
            LeftArray <KeyValue <Type, Exception> > exceptionTypeArray = new LeftArray <KeyValue <Type, Exception> >(0);
            IRoot root = Common.Root;

            if (object.ReferenceEquals(root, Root.Null))
            {
                Assembly assembly = Assembly.GetEntryAssembly();
                if (assembly != null)
                {
                    foreach (Type type in assembly.GetTypes())
                    {
                        if (typeof(IRoot).IsAssignableFrom(type))
                        {
                            try
                            {
                                root = (IRoot)Activator.CreateInstance(type);
                                break;
                            }
                            catch (Exception exception)
                            {
                                exceptionTypeArray.Add(new KeyValue <Type, Exception>(type, exception));
                            }
                        }
                    }
                }
            }

            foreach (Type type in root.MainTypes.concat(root.PublicTypes))
            {
                foreach (FieldInfo field in type.GetFields(BindingFlags.Static | BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.NonPublic))
                {
                    foreach (MemberAttribute attribute in field.GetCustomAttributes(typeof(MemberAttribute), false))
                    {
                        HashKey <HashType, string> key = new HashKey <HashType, string>(field.FieldType, attribute.GetCacheName(field.Name));
                        if (!cache.ContainsKey(key))
                        {
                            cache.Add(key, new Creator.Field(field));
                        }
                        break;
                    }
                }
                foreach (PropertyInfo property in type.GetProperties(BindingFlags.Static | BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.NonPublic))
                {
                    if (property.CanRead)
                    {
                        MethodInfo method = property.GetGetMethod(true);
                        if (method != null && method.GetParameters().Length == 0)
                        {
                            foreach (MemberAttribute attribute in property.GetCustomAttributes(typeof(MemberAttribute), false))
                            {
                                HashKey <HashType, string> key = new HashKey <HashType, string>(property.PropertyType, attribute.GetCacheName(property.Name));
                                if (!cache.ContainsKey(key))
                                {
                                    cache.Add(key, new Creator.Property(method));
                                }
                                break;
                            }
                        }
                    }
                }
            }

            if (exceptionTypeArray.Length != 0)
            {
                root.OnLoadException(ref exceptionTypeArray);
            }
        }
Exemplo n.º 34
0
 public BootState(IRoot root, ILevelInitializer levelInitializer)
 {
     this.root             = root;
     this.levelInitializer = levelInitializer;
 }
Exemplo n.º 35
0
        private List <ISection> CreateSectionList(UIView view, IRoot root)
        {
            var memberFuncMap = new List <Func <object, MemberInfo[]> >()
            {
                (T) => GetFields(T),
                (T) => GetProperties(T),
                (T) => GetMethods(T)
            };

            ISection lastSection = new Section()
            {
                Order = -1, Parent = root as IElement
            };

            var sectionList = new List <ISection>()
            {
                lastSection
            };

            IElement newElement = null;
            Theme    theme      = null;
            var      themeable  = root as IThemeable;

            if (themeable != null)
            {
                ThemeHelper.ApplyRootTheme(view, themeable);
                theme = themeable.Theme;
                ThemeHelper.ApplyElementTheme(theme, lastSection, null);
            }

            if (!(view is IView))
            {
                newElement = new UIViewElement(null, view, false);
                lastSection.Add(newElement);
            }
            else
            {
                foreach (var memberFunc in memberFuncMap)
                {
                    var members = memberFunc(view);

                    foreach (var member in members)
                    {
                        var isList = member.GetCustomAttribute <ListAttribute>() != null;

                        var pullToRefreshAttribute = member.GetCustomAttribute <PullToRefreshAttribute>();
                        if (pullToRefreshAttribute != null)
                        {
                            root.PullToRefreshCommand = GetCommandForMember(view, member);
                            root.DefaultSettingsKey   = pullToRefreshAttribute.SettingsKey;
                        }
                        var skipAttribute = member.GetCustomAttribute <SkipAttribute>(true);
                        if (skipAttribute != null)
                        {
                            continue;
                        }

                        var sectionAttribute = member.GetCustomAttribute <SectionAttribute>();

                        if (sectionAttribute != null)
                        {
                            Theme sectionTheme = null;
                            if (sectionAttribute.ThemeType != null)
                            {
                                sectionTheme = Activator.CreateInstance(sectionAttribute.ThemeType) as Theme;
                            }

                            lastSection = new Section(sectionAttribute.Caption, sectionAttribute.Footer)
                            {
                                Order = sectionAttribute.Order
                            };
                            lastSection.Parent = root as IElement;

                            ThemeHelper.ApplyElementTheme(root.Theme, lastSection, null);
                            ThemeHelper.ApplyElementTheme(sectionTheme, lastSection, null);

                            sectionList.Add(lastSection);
                        }

                        var bindings = GetBindings(view, member);

                        newElement = GetElementForMember(root.Theme, view, member, bindings);

                        ThemeHelper.ApplyElementTheme(theme, newElement, member);

                        IBindable bindable = null;

                        if (newElement is ISection)
                        {
                            lastSection.Add(((ISection)newElement).Elements);
                            bindable = lastSection as IBindable;
                        }
                        else if (newElement != null)
                        {
                            bindable = newElement as IBindable;

                            if ((isList) && newElement is IRoot)
                            {
                                var sections = ((IRoot)newElement).Sections;

                                var firstSection = sections.FirstOrDefault();
                                if (firstSection.Elements.Count > 0)
                                {
                                    lastSection.Add(firstSection.Elements);
                                }

                                for (var index = 1; index < sections.Count; index++)
                                {
                                    sectionList.Add(sections[index]);
                                }
                            }
                            else
                            {
                                lastSection.Add(newElement);
                            }
                        }

                        if (bindable != null && bindable != _NoElement && bindings.Count != 0)
                        {
                            foreach (Binding binding in bindings)
                            {
                                if (binding.TargetPath == null)
                                {
                                    binding.TargetPath = "DataContext";
                                }

                                BindingOperations.SetBinding(bindable, binding.TargetPath, binding);
                            }
                        }
                    }
                }
            }

            foreach (var section in sectionList)
            {
                var orderedList = section.Elements.OrderBy(e => e.Order).Where((e) => e != _NoElement).ToList();
                section.Elements = new System.Collections.ObjectModel.ObservableCollection <MonoMobile.MVVM.IElement>(orderedList);
            }

            var orderedSections = sectionList.Where(s => s.Elements.Count > 0).OrderBy(section => section.Order).ToList();

            return(orderedSections);
        }
Exemplo n.º 36
0
        private List <ISection> CreateSectionList(object view, IRoot root)
        {
            var memberFuncMap = new List <Func <object, MemberInfo[]> >()
            {
                (T) => GetFields(T),
                (T) => GetProperties(T),
                (T) => GetMethods(T)
            };

            ISection lastSection = new Section()
            {
                Order = -1, Parent = root as IElement
            };

            var sectionList = new List <ISection>()
            {
                lastSection
            };

            IElement newElement = null;
            Theme    theme      = null;
            var      themeable  = root as IThemeable;

            if (themeable != null)
            {
                ApplyRootTheme(view, themeable);
                theme = themeable.Theme;
                ApplyElementTheme(theme, lastSection, null);
            }

            foreach (var memberFunc in memberFuncMap)
            {
                var members = memberFunc(view);

                foreach (var member in members)
                {
                    var pullToRefreshAttribute = member.GetCustomAttribute <PullToRefreshAttribute>();
                    if (pullToRefreshAttribute != null)
                    {
                        root.PullToRefreshCommand = GetCommandForMember(view, member);
                        root.DefaultSettingsKey   = pullToRefreshAttribute.SettingsKey;
                    }
                    var skipAttribute = member.GetCustomAttribute <SkipAttribute>(true);
                    if (skipAttribute != null)
                    {
                        continue;
                    }

                    var inline = member.GetCustomAttribute <InlineAttribute>() != null;
                    //	var isRoot = member.GetCustomAttribute<RootAttribute>() != null;
                    var listAttribute    = member.GetCustomAttribute <ListAttribute>();
                    var isList           = listAttribute != null;
                    var sectionAttribute = member.GetCustomAttribute <SectionAttribute>();

                    if (sectionAttribute != null)
                    {
                        Theme sectionTheme = null;
                        if (sectionAttribute.ThemeType != null)
                        {
                            sectionTheme = Activator.CreateInstance(sectionAttribute.ThemeType) as Theme;
                        }

                        lastSection = new Section(sectionAttribute.Caption, sectionAttribute.Footer)
                        {
                            Order = sectionAttribute.Order
                        };
                        lastSection.Parent = root as IElement;
                        ApplyElementTheme(root.Theme, lastSection, null);

                        ApplyElementTheme(sectionTheme, lastSection, null);
                        sectionList.Add(lastSection);
                    }

                    newElement = GetElementForMember(view, member);

                    if (newElement != null)
                    {
                        newElement.Theme.MergeTheme(root.Theme);
                        ApplyElementTheme(root.Theme, newElement, member);

                        //var context = newElement as IView;
                        //	var displayInline = (inline || !isRoot) && newElement is IRoot; //&& context != null;

                        if (isList)
                        {
                            var  newRoot  = newElement as IRoot;
                            Type viewType = newRoot.ViewBinding.ViewType ?? listAttribute.ViewType;

                            string caption = null;
                            if (!(view is IDataTemplate))
                            {
                                caption = newElement.Caption;
                            }

                            lastSection = new Section(caption, null)
                            {
                            };
                            lastSection.Parent = root as IElement;
                            ApplyElementTheme(root.Theme, lastSection, null);
                            sectionList.Add(lastSection);

                            IEnumerable datacontext = null;
                            if (view is IDataTemplate)
                            {
                                datacontext = ((IDataTemplate)view).Items;
                            }
                            else
                            {
                                datacontext = (IEnumerable)GetValue(member, view);
                            }

                            foreach (var e in datacontext)
                            {
                                IElement element = null;

                                if (e is IViewModel)
                                {
                                    element = new RootElement(e.ToString());
                                    element.ViewBinding.ViewType    = viewType;
                                    element.ViewBinding.DataContext = e;

                                    ((IRoot)element).Theme = Theme.CreateTheme(root.Theme);
                                    element.Theme          = ((IRoot)element).Theme;

                                    if (listAttribute.ThemeType != null)
                                    {
                                        var listTheme = Activator.CreateInstance(listAttribute.ThemeType) as Theme;
                                        var rootTheme = Theme.CreateTheme(((IRoot)element).Theme);
                                        rootTheme.MergeTheme(listTheme);
                                        ((IRoot)element).Theme = rootTheme;
                                    }
                                }
                                else
                                {
                                    element       = new RadioElement(e.ToString());
                                    element.Theme = ((IRoot)element).Theme;
                                }

                                lastSection.Add(element);
                            }
                        }
                        else if (inline)
                        {
                            var inlineSection = new Section(string.Empty, null)
                            {
                            };
                            ApplyElementTheme(newElement.Theme, inlineSection, null);
                            inlineSection.Parent = root as IElement;
                            sectionList.Add(inlineSection);

                            IRoot inlineRoot = newElement as IRoot;
                            if (newElement.ViewBinding.DataContextCode == DataContextCode.Object)
                            {
                                var bindingContext = new BindingContext(newElement.ViewBinding.CurrentView, newElement.Caption, newElement.Theme);
                                inlineRoot = bindingContext.Root;
                            }

                            inlineSection.Caption = newElement.Caption;

                            foreach (var element in inlineRoot.Sections[0].Elements)
                            {
                                inlineSection.Add(element);
                            }

                            //root.Groups.Add(inlineRoot.Groups[0]);
                        }
                        else
                        {
                            lastSection.Add(newElement);
                        }
                    }
                }
            }

            foreach (var section in sectionList)
            {
                var orderedList = section.Elements.OrderBy(e => e.Order).ToList();
                section.Elements = orderedList;
            }

            var orderedSections = sectionList.Where(s => s.Elements.Count > 0).OrderBy(section => section.Order).ToList();

            return(orderedSections);
        }
Exemplo n.º 37
0
 public static Node2D AsNode(this IRoot self)
 {
     return(self as Node2D ??
            throw new Exception($"object implementing {nameof(IRoot)} but does not extend {nameof(Node2D)}"));
 }
Exemplo n.º 38
0
 public static string Name(this IRoot self)
 {
     return(self.AsNode().Name);
 }
		public DialogViewController(UITableViewStyle style, IRoot root) : base(style)
		{
			PrepareRoot(root);
		}
 public Source(DialogViewController container)
 {
     Container = container;
     Root      = container.Root;
 }
		/// <summary>
		///     Creates a new DialogViewController from a IRoot and sets the push status
		/// </summary>
		/// <param name="_Root">
		/// The <see cref="IRoot"/> containing the information to render.
		/// </param>
		/// <param name="_Pushing">
		/// A <see cref="System.Boolean"/> describing whether this is being pushed 
		/// (NavigationControllers) or not.   If _Pushing is true, then the back button 
		/// will be shown, allowing the user to go back to the previous controller
		/// </param>
		public DialogViewController(IRoot root, bool pushing) : base(UITableViewStyle.Grouped)
		{
			_Pushing = pushing;
			PrepareRoot(root);
		}
Exemplo n.º 42
0
		public static IElement CreateElementFromObject(object item, IRoot root, Type elementType)
		{
			var caption = item.ToString();
			if (string.IsNullOrEmpty(caption))
			{
				caption = root.ViewBinding.ViewType.Name.Capitalize();
			}
			
			if (elementType == null)
				elementType = typeof(RadioElement);

			var element = Activator.CreateInstance(elementType) as IElement;
			element.Caption = caption;
			element.DataContext = item;
			element.ViewBinding.DataContextCode = DataContextCode.Object;

			if (root != null)
			{
				element.ViewBinding.ViewType = root.ViewBinding.ViewType;
				element.ViewBinding.MemberInfo = root.ViewBinding.MemberInfo;
				element.EditingStyle = root.EditingStyle;
				element.Theme.MergeTheme(root.Theme);
			}

			var uiView = element as UIView;
			if (uiView != null)
				uiView.Opaque = false;

			if (item is UIView)
				element.ViewBinding.View = item as UIView;

			if (element.ViewBinding.ViewType == null)
				element.ViewBinding.ViewType = item.GetType();

			return element;
		}
			public Source(DialogViewController container)
			{
				Container = container;
				Root = container.Root;
			}
Exemplo n.º 44
0
//		public static IRoot CreateRootElementFromObject(Type elementType, object obj)
//		{
//			elementType = elementType ?? typeof(RootElement);
//
//			object context = obj;
//			MemberInfo dataContextMember = GetMemberFromDataContext(member, ref context);
//			var items = dataContextMember.GetValue(context);
//
//			var rootElement = Activator.CreateInstance(elementType) as IElement;
//			
//			((Element)rootElement).Opaque = false;
//			rootElement.Caption = caption;
//			rootElement.Theme = Theme.CreateTheme(Root.Theme); 
//			rootElement.ViewBinding.MemberInfo = dataContextMember;
//			rootElement.ViewBinding.ElementType = elementType;
//			rootElement.ViewBinding.ViewType = viewType;
//			rootElement.ViewBinding.DataContextCode = DataContextCode.Object;
//			rootElement.Theme.CellStyle = GetCellStyle(member, UITableViewCellStyle.Default);
//
//			if (cellEditingStyle != null)
//				rootElement.EditingStyle = cellEditingStyle.EditingStyle;
//
//			if (items != null)
//			{
//				if (items is UIView)
//				{				
//					rootElement.ViewBinding.View = items as UIView;
//				}
//				else
//				{
//					rootElement.DataContext = items;
//				}
//			}
//			else
//				rootElement.DataContext = context;
//
//			if (genericType != null)
//			{
//				SetDefaultConverter(view, member, "DataContext", new EnumerableConverter(), null, bindings);
//				rootElement.ViewBinding.DataContextCode = DataContextCode.ViewEnumerable;
//				rootElement.ViewBinding.ViewType = viewType;
//			}
//
//			if (isList)
//			{
//				var innerRoot = BindingContext.CreateRootedView(rootElement as IRoot);
//				root = innerRoot as IElement;
//			}
//			else
//			{
//				root = rootElement;
//			}
//		}
		
		private static IRoot CreateObjectRoot(IRoot root)
		{
			IRoot newRoot = null;
			UIView view = null;
			object context = root.DataContext;
	
			if (root.ViewBinding.View != null)
			{
				view = root.ViewBinding.View;
				if (root.ViewBinding.MemberInfo != null && root.ViewBinding.DataContext != null)
				{
					var memberValue = root.ViewBinding.MemberInfo.GetValue(root.ViewBinding.DataContext) as UIView;

					if (memberValue != null)
						view = memberValue;
				}
			}
			else
			{
				if (root.ViewBinding.ViewType != null)
				{
					view = Activator.CreateInstance(root.ViewBinding.ViewType) as UIView;
				}
			}

			var dataContext = view as IDataContext;
			if (dataContext != null)
			{
				dataContext.DataContext = context;

				var lifetime = context as IInitializable;
				if (lifetime != null)
					lifetime.Initialize();
				
				lifetime = dataContext as IInitializable;
				if (lifetime != null)
					lifetime.Initialize();
			}
			
			var bindingContext = new BindingContext(view, root.Caption, root.Theme);

			newRoot = (IRoot)bindingContext.Root;
			newRoot.ViewBinding = root.ViewBinding;
			newRoot.ViewBinding.View = view;
			
			return newRoot;
		}
Exemplo n.º 45
0
 private void Populate(object dataContext, IRoot root)
 {
     root.Add(CreateSectionList(dataContext, root));
 }
 public DialogViewController(UITableViewStyle style, IRoot root, bool pushing) : base(style)
 {
     _Pushing = pushing;
     Style    = style;
     PrepareRoot(root);
 }
Exemplo n.º 47
0
        public SyntaxTree GetSyntaxTree(IRoot root)
        {
            var rootNode = GetSyntaxNode(root);

            return(SyntaxFactory.SyntaxTree(rootNode));
        }
Exemplo n.º 48
0
 public static void SetInstance(IRoot instance)
 {
     _instance = instance;
 }
Exemplo n.º 49
0
		public static Section CreateSection(IRoot root, Section section, object dataContext, Type elementType, bool popOnSelection)
		{
			var items = dataContext as IEnumerable;
			if (items != null)
			{
				if (section == null)
					section = new Section();
				
				//section.Clear();	
				section.Parent = root;

				foreach (var item in items)
				{
					var element = CreateElementFromObject(item, root, elementType);
					section.Add(element);
				}
			}

			return section;
		}
Exemplo n.º 50
0
 public StringRoot(IRoot <string> root) : base(root)
 {
 }
Exemplo n.º 51
0
		public static IRoot CreateViewEnumerableRoot(IRoot root)
		{
			IRoot newRoot = null;

			Type elementType = root.ViewBinding.ElementType;
			if (elementType == null)
				elementType = typeof(RootElement);

			newRoot = new RootElement() { ViewBinding = root.ViewBinding, EditingStyle = root.EditingStyle };
			
			var section = new Section() { ViewBinding = root.ViewBinding, Parent = newRoot as IElement };

			newRoot.Sections.Add(section);
			
			section = CreateSection(newRoot, section, root.DataContext, elementType, false);
		
			Theme.ApplyElementTheme(root.Theme, newRoot, null);

			return newRoot;
		}
 public void TestFixtureSetUp()
 {
     _root = new Root(TestConfig.RepositoryPath, TestConfig.ModuleName, TestConfig.CVSHost, TestConfig.CVSPort, TestConfig.Username, TestConfig.Password);
 }
Exemplo n.º 53
0
        public static void TestCompileFile()
        {
            if (TestOff)
            {
                return;
            }

            Compiler Compiler = new Compiler();

            Assert.That(Compiler != null, "Sanity Check #0");

            string TestFileName = $"{RootPath}coverage/coverage.easly";

            Exception ex;
            string    NullString = null;

            ex = Assert.Throws <ArgumentNullException>(() => Compiler.Compile(NullString));
            Assert.That(ex.Message == $"Value cannot be null.{NL}Parameter name: fileName", ex.Message);

            Compiler.Compile("notfound.easly");
            Assert.That(!Compiler.ErrorList.IsEmpty && Compiler.ErrorList.At(0) is IErrorInputFileNotFound AsInputFileNotFound && AsInputFileNotFound.Message == "File not found: 'notfound.easly'.", ErrorListToString(Compiler));

            using (FileStream fs = new FileStream(TestFileName, FileMode.Open, FileAccess.ReadWrite, FileShare.None))
            {
                Compiler.Compile(TestFileName);
                Assert.That(!Compiler.ErrorList.IsEmpty && Compiler.ErrorList.At(0) is IErrorInputFileInvalid, ErrorListToString(Compiler));
            }

            Stream NullStream = null;

            ex = Assert.Throws <ArgumentNullException>(() => Compiler.Compile(NullStream));
            Assert.That(ex.Message == $"Value cannot be null.{NL}Parameter name: stream", ex.Message);

            Compiler.Compile(TestFileName);
            Assert.That(Compiler.ErrorList.IsEmpty, ErrorListToString(Compiler));

            string InvalidFile = File.Exists($"{RootPath}Test-Easly-Compiler.dll") ? $"{RootPath}Test-Easly-Compiler.dll" : $"{RootPath}Test-Easly-Compiler.csproj";

            using (FileStream fs = new FileStream(InvalidFile, FileMode.Open, FileAccess.Read))
            {
                Compiler.Compile(fs);
                Assert.That(!Compiler.ErrorList.IsEmpty && Compiler.ErrorList.At(0) is IErrorInputFileInvalid, ErrorListToString(Compiler));
            }

            IRoot NullRoot = null;

            ex = Assert.Throws <ArgumentNullException>(() => Compiler.Compile(NullRoot));
            Assert.That(ex.Message == $"Value cannot be null.{NL}Parameter name: root", ex.Message);

            using (FileStream fs = new FileStream(TestFileName, FileMode.Open, FileAccess.Read))
            {
                Compiler.Compile(fs);
                Assert.That(Compiler.ErrorList.IsEmpty, ErrorListToString(Compiler));
            }

            IRoot ClonedRoot = NodeHelper.DeepCloneNode(CoverageNode, cloneCommentGuid: true) as IRoot;

            NodeTreeHelper.SetGuidProperty(ClonedRoot.ClassBlocks.NodeBlockList[0].NodeList[0], nameof(IClass.ClassGuid), Guid.Empty);
            Assert.That(!NodeTreeDiagnostic.IsValid(ClonedRoot, assertValid: false));

            Compiler.Compile(ClonedRoot);
            Assert.That(!Compiler.ErrorList.IsEmpty && Compiler.ErrorList.At(0) is IErrorInputRootInvalid, ErrorListToString(Compiler));
        }
Exemplo n.º 54
0
 public Child(IContainer container, IRoot root)
 {
     this.container = container;
     this.root      = root;
     child2         = container.Get <Child2>();
 }
Exemplo n.º 55
0
 public AccountController(IRoot _root)
 {
     root = _root;
 }
Exemplo n.º 56
0
 public ListViewSource(ListView listViewContainer)
 {
     Container = listViewContainer;
     Root      = listViewContainer.Root;
 }
Exemplo n.º 57
0
		private static IRoot CreateViewEnumerableRoot(IRoot root)
		{
			IRoot newRoot = null;

			Type elementType = root.ViewBinding.ElementType;
			if (elementType == null)
				elementType = typeof(RootElement);

			newRoot = new RootElement() { Opaque = false, ViewBinding = root.ViewBinding };
			IElement element = null;
			
			var items = (IEnumerable)root.DataContext;
			var section = new Section() { Opaque = false, ViewBinding = root.ViewBinding, Parent = newRoot as IElement };

			newRoot.Sections.Add(section);

			foreach (var e in items)
			{
				var caption = e.ToString();
				if (string.IsNullOrEmpty(caption))
				{
					caption = MakeCaption(root.ViewBinding.ViewType.Name);
				}
				
				element = Activator.CreateInstance(elementType) as IElement;
				((RootElement)element).Opaque = false;
				element.Caption = caption;
				element.ViewBinding.DataContextCode = DataContextCode.Object;
				element.ViewBinding.ViewType = root.ViewBinding.ViewType;
				element.ViewBinding.MemberInfo = root.ViewBinding.MemberInfo;

				if (e is UIView)
					element.ViewBinding.View = e as UIView;
				else
					element.DataContext = e;

				if (element.ViewBinding.ViewType == null)
					element.ViewBinding.ViewType = e.GetType();

				section.Add(element);
			}
		
			ThemeHelper.ApplyElementTheme(root.Theme, newRoot, null);

			return newRoot;
		}
		public DialogViewController(IRoot root) : base(UITableViewStyle.Grouped)
		{
			PrepareRoot(root);
		}
Exemplo n.º 59
0
 public override RootData GetRootData(IRoot <T> root)
 {
     return(dictionary[root]);
 }
 public DialogViewController(UITableViewStyle style, IRoot root) : base(style)
 {
     PrepareRoot(root);
 }