Esempio n. 1
0
        public DirectiveCollection GetDirectivesFromAllAircrafts(DirectiveType directiveType, string text, string paragraph)
        {
            if (directiveType == null)
            {
                directiveType = DirectiveType.AirworthenessDirectives;
            }

            var qrs = DirectiveQueries.GetSelectQuery(directiveType, text, paragraph, loadChild: true);

            var directives = new DirectiveCollection();

            directives.AddRange(_loader.GetObjectListAll <Directive>(qrs, true));

            if (directives.Count == 0)
            {
                return(directives);
            }

            var directiveIds   = directives.Select(d => d.ItemId).ToList();
            var itemsRelations = _itemsRelationsDataAccess.GetRelations(directiveIds, SmartCoreType.Directive.ItemId);

            if (itemsRelations.Count > 0)
            {
                foreach (var directive in directives)
                {
                    directive.ItemRelations.AddRange(itemsRelations.Where(i => i.FirstItemId == directive.ItemId || i.SecondItemId == directive.ItemId));
                }
            }

            return(directives);
        }
Esempio n. 2
0
        public void Visit <TDirective>(DirectiveType <TDirective> directiveType)
            where TDirective : class
        {
            // get CLR type that maps to a GraphQL directive
            TDirective directive = this.directive.ToObject <TDirective>();

            if (directive == null)
            {
                throw new Exception("Given GraphQL directive was not declared by validation directive type");
            }

            // get validation handler for validation directive
            IValidator <TDirective> validator = this.services.GetService <IValidator <TDirective> >();

            if (validator == null)
            {
                throw new Exception($"Validator {typeof(IValidator<TDirective>).Name} not registered");
            }

            var result = validator.Validate(directive, this.value);

            if (!result.Valid)
            {
                var error = new Error(directiveType.Name, result.ErrorMessage);
                ctx.Add(error);
            }
        }
        public void EnsureSkipDirectiveIsAvailable()
        {
            // arrange
            ISchema schema = CreateSchema(b => { });

            // act
            DirectiveType directive =
                schema.DirectiveTypes.FirstOrDefault(
                    t => t.Name.Equals("skip"));

            // assert
            Assert.NotNull(directive);
            Assert.IsType <SkipDirectiveType>(directive);
            Assert.Equal("skip", directive.Name);
            Assert.Collection(directive.Arguments,
                              t =>
            {
                Assert.Equal("if", t.Name);
                Assert.IsType <NonNullType>(t.Type);
                Assert.IsType <BooleanType>(((NonNullType)t.Type).Type);
            });
            Assert.Collection(directive.Locations,
                              t => Assert.Equal(DirectiveLocation.Field, t),
                              t => Assert.Equal(DirectiveLocation.FragmentSpread, t),
                              t => Assert.Equal(DirectiveLocation.InlineFragment, t));
        }
Esempio n. 4
0
        public Directive(string nameWithoutDot, string unquotedArgument)
        {
            this.Type = (DirectiveType)Enum.Parse(typeof(DirectiveType), nameWithoutDot, true);
            RawArgumentWithoutQuotes = unquotedArgument;

            switch (this.Type)
            {
            case DirectiveType.@byte:
                this.LengthInBytes = 1;
                break;

            case DirectiveType.word:
                this.LengthInBytes = 2;
                break;

            case DirectiveType.@string:
                this.LengthInBytes = unquotedArgument.Length;
                this.Bytes         = Encoding.ASCII.GetBytes(unquotedArgument);
                break;

            case DirectiveType.org:
                this.LengthInBytes = 0;
                this.Bytes         = new byte[0];
                break;
            }
        }
Esempio n. 5
0
        ///<summary>
        /// Создается объект, описывающий отображение добавления директивы
        ///</summary>
        /// <param name="directiveContainer">Родительский объект, в который добавляется директива</param>
        public OutOfPhaseReferenceScreen(BaseEntityObject directiveContainer)
            : this()
        {
            if (directiveContainer == null)
            {
                throw new ArgumentNullException("directiveContainer");
            }

            _directiveType = DirectiveType.OutOfPhase;

            if (directiveContainer is BaseComponent)
            {
                var baseComponent = (BaseComponent)directiveContainer;
                _currentBaseComponent = baseComponent;
                _currentOutOfPhase    = new Directive {
                    ParentBaseComponent = baseComponent, DirectiveType = _directiveType
                };
            }
            else
            {
                var aircraftFrame = GlobalObjects.ComponentCore.GetBaseComponentById(((Aircraft)directiveContainer).AircraftFrameId);
                _currentOutOfPhase = new Directive {
                    ParentBaseComponent = aircraftFrame, DirectiveType = _directiveType
                };
            }
            Initialize();
        }
Esempio n. 6
0
        public async Task <List <DirectiveView> > GetDirectives(int aircraftId, DirectiveType directiveType,
                                                                ADType?adType = null)
        {
            var basecomponentIds = await _componentRepository.GetAircraftBaseComponentIds(aircraftId);

            var query = _db.Directives
                        .Where(FilterByType(basecomponentIds, directiveType))
                        .Include(i => i.ATAChapter)
                        .AsNoTracking()
                        .OnlyActive();

            if (adType != null)
            {
                query = query.Where(i => i.ADType == (short)adType);
            }

            var directives = await query.ToListAsync();

            var ids       = directives.Select(i => i.Id);
            var fileLinks = await _db.ItemFileLinks
                            .AsNoTracking()
                            .Where(i => i.ParentTypeId == SmartCoreType.Directive.ItemId && ids.Contains(i.ParentId))
                            .ToListAsync();

            var view = directives.ToBlView();

            foreach (var directiveView in view)
            {
                directiveView.ItemFileLink.AddRange(fileLinks.Where(i => i.ParentId == directiveView.Id));
            }

            return(view);
        }
Esempio n. 7
0
        public static void MergeDirectives(
            ITypeCompletionContext context,
            IList <DirectiveDefinition> extension,
            IList <DirectiveDefinition> type)
        {
            var directives = new List <(DirectiveType type, DirectiveDefinition def)>();

            foreach (DirectiveDefinition directive in type)
            {
                DirectiveType directiveType = context.GetDirectiveType(directive.Reference);
                directives.Add((directiveType, directive));
            }

            foreach (DirectiveDefinition directive in extension)
            {
                MergeDirective(context, directives, directive);
            }

            type.Clear();

            foreach (DirectiveDefinition directive in directives.Select(t => t.def))
            {
                type.Add(directive);
            }
        }
Esempio n. 8
0
 /// <summary>
 /// Tries to get a directive type by its name.
 /// </summary>
 /// <param name="directiveName">
 /// The directive name.
 /// </param>
 /// <param name="directiveType">
 /// The directive type that was resolved by the given name
 /// or <c>null</c> if there is no directive with the specified name.
 /// </param>
 /// <returns>
 /// <c>true</c>, if a directive type with the specified
 /// name exists; otherwise, <c>false</c>.
 /// </returns>
 public bool TryGetDirectiveType(
     string directiveName,
     out DirectiveType directiveType)
 {
     return(_directiveTypes
            .TryGetValue(directiveName, out directiveType));
 }
Esempio n. 9
0
        /// <summary>
        ///  Создаёт экземпляр элемента управления, отображающего список директив
        /// </summary>
        /// <param name="adType"></param>
        public DefferedListScreen(Operator @operator, ADType adType = ADType.None) : this()
        {
            if (@operator == null)
            {
                throw new ArgumentNullException("@operator");
            }

            var primaryDirectiveType = DirectiveType.DeferredItems;


            CurrentOperator = @operator;
            StatusTitle     = @operator.Name + " " + primaryDirectiveType.CommonName;

            _currentPrimaryDirectiveType = primaryDirectiveType;
            _adType = adType;


            var directiveList = new DefferedListView();

            _filter  = new CommonFilterCollection(typeof(DeferredItem));
            _builder = new DeferredListReportBuilder();

            InitToolStripMenuItems();
            InitPrintToolStripMenuItems();
            InitListView(directiveList);
        }
Esempio n. 10
0
        /// <summary>
        /// Возвращает строку запроса на получение всех облуживания рабочего пакета
        /// </summary>
        /// <param name="workPackageId"></param>
        /// <param name="directiveType"></param>
        /// <param name="filters"></param>
        /// <param name="loadChild"></param>
        /// <returns></returns>
        public static List <DbQuery> GetSelectQueryForWp(int workPackageId, DirectiveType directiveType,
                                                         ICommonFilter[] filters = null,
                                                         bool loadChild          = false)
        {
            var directiveIn = BaseQueries.GetSelectQueryColumnOnly <WorkPackageRecord>(WorkPackageRecord.DirectiveIdProperty,
                                                                                       new ICommonFilter[]
            {
                new CommonFilter <int>(WorkPackageRecord.WorkPakageIdProperty, workPackageId),
                new CommonFilter <int>(WorkPackageRecord.WorkPackageItemTypeProperty, SmartCoreType.Directive.ItemId)
            });

            List <ICommonFilter> allFilters =
                new List <ICommonFilter>
            {
                new CommonFilter <string>(BaseEntityObject.ItemIdProperty, FilterType.In, new[] { directiveIn })
            };

            if (filters != null && filters.Length > 0)
            {
                allFilters.AddRange(filters);
            }
            allFilters.Add(GetWhereStatement(directiveType));

            return(BaseQueries.GetSelectQueryWithWhereAll <Directive>(allFilters.ToArray(), loadChild, true));
        }
Esempio n. 11
0
 private void VisitDirective(DirectiveType type)
 {
     foreach (Argument argument in type.Arguments)
     {
         VisitDirectives(argument);
         Visit((TypeSystemObjectBase)argument.Type.NamedType());
     }
 }
Esempio n. 12
0
 /// <summary>
 /// Tries to get a directive type by its name.
 /// </summary>
 /// <param name="directiveName">
 /// The directive name.
 /// </param>
 /// <param name="directiveType">
 /// The directive type that was resolved by the given name
 /// or <c>null</c> if there is no directive with the specified name.
 /// </param>
 /// <returns>
 /// <c>true</c>, if a directive type with the specified
 /// name exists; otherwise, <c>false</c>.
 /// </returns>
 public bool TryGetDirectiveType(
     NameString directiveName,
     out DirectiveType directiveType)
 {
     return(_directiveTypes.TryGetValue(
                directiveName.EnsureNotEmpty(nameof(directiveName)),
                out directiveType));
 }
Esempio n. 13
0
        public void Test(DirectiveType type, Type expectedType)
        {
            DirectiveParserFactory factory = new DirectiveParserFactory();

            DirectiveParser parser = factory.GetParser(type);

            Assert.AreEqual(expectedType, parser?.GetType());
        }
Esempio n. 14
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="ScriptDirective"/> class.
 /// </summary>
 /// <param name="rawValue">The raw value.</param>
 /// <param name="pathOfCallingScript">The path of calling script.</param>
 /// <param name="callingScriptLineNumber">The calling script line number.</param>
 /// <param name="originalReferencePath">The original reference path.</param>
 /// <param name="type">The type.</param>
 public ScriptDirective(string rawValue, string pathOfCallingScript, int callingScriptLineNumber, string originalReferencePath, DirectiveType type)
 {
     RawValue                = rawValue;
     PathOfCallingScript     = pathOfCallingScript;
     CallingScriptLineNumber = callingScriptLineNumber;
     OriginalReferencePath   = originalReferencePath;
     Type = type;
 }
Esempio n. 15
0
 /// <summary>
 /// Создается элемент - отображение директив для заданого типа директив
 /// </summary>
 /// <param name="directive">Директива для которой требуется создать элемент - отображения</param>
 public DispatcheredСertainDirectivesView(BaseDetailDirective directive)
 {
     currentDirective           = directive;
     dictionaryDirectiveFilters = (SortedList <string, IFilter>)(new TermsProvider()[("DirectiveFilterTypes")]);
     reportTitileText           = directive.DirectiveType.CommonName;
     directiveFilters           = new DirectiveFilter[] { dictionaryDirectiveFilters[directive.DirectiveType.CommonName] as DirectiveFilter };
     directiveDefaultType       = directive.DirectiveType;
     Initialize((directive.Parent is AircraftFrame ? directive.Parent.Parent:directive.Parent)  as IDirectiveContainer);
 }
Esempio n. 16
0
 ///<summary>
 ///</summary>
 public DirectiveFleetListView(DirectiveType primaryDirectiveType) : this()
 {
     EnableCustomSorting         = false;
     CurrentPrimatyDirectiveType = primaryDirectiveType;
     ColumnHeaderList.Clear();
     SetHeaders();
     radGridView1.Columns.Clear();
     radGridView1.Columns.AddRange(ColumnHeaderList.ToArray());
 }
 public void EnsureDirectiveKnown(DirectiveType type)
 {
     if (!Builder.TryGetDirective(type.Name, out _))
     {
         throw new SchemaBuilderException(
                   type.Name,
                   $"Directive {type} is not known by the builder.");
     }
 }
Esempio n. 18
0
        public ISchemaBuilder AddDirectiveType(DirectiveType type)
        {
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }

            _types.Add(new SchemaTypeReference(type));
            return(this);
        }
Esempio n. 19
0
        /// <summary>
        /// Возвращает условие того деталь принадлежит базовому агрегату
        /// </summary>
        /// <param name="directiveType"></param>
        /// <returns></returns>
        public static ICommonFilter GetWhereStatement(DirectiveType directiveType)
        {
            if (directiveType == null)
            {
                throw new ArgumentNullException("directiveType", "must be not null");
            }
            if (DirectiveType.GetDirectiveTypeById(directiveType.ItemId) == DirectiveType.Unknown)
            {
                throw new ArgumentException("unknown directive type", "directiveType");
            }

            ICommonFilter state;

            if (directiveType == DirectiveType.All)
            {
                DirectiveType[] s =
                { DirectiveType.AirworthenessDirectives,
                  DirectiveType.DamagesRequiring,
                  DirectiveType.EngineeringOrders,
                  DirectiveType.OutOfPhase,
                  DirectiveType.SB };

                state = new CommonFilter <DirectiveType>(Directive.DirectiveTypeProperty, FilterType.In, s);
            }
            else if (directiveType == DirectiveType.EngineeringOrders)
            {
                state =
                    new CommonFilter <string>($@" (directives.EngineeringOrders <> '' 
                                      or directives.EngineeringOrderFileID > 0 
                                      or directives.DirectiveType = {directiveType.ItemId})");
            }
            else if (directiveType == DirectiveType.ModificationStatus)
            {
                state = new CommonFilter <DirectiveWorkType>(Directive.WorkTypeProperty, DirectiveWorkType.Modification);
            }
            else if (directiveType == DirectiveType.SB)
            {
                //state =
                //    new CommonFilter<string>(string.Format(@"((directives.ServiceBulletinNo <> ''
                //                                           or directives.ServiceBulletinFileID > 0 )
                //                                           and directives.DirectiveType = {0})", directiveType.ItemId));
                //TODO: Было так но потом захотели sb в ad перемещать
                state = new CommonFilter <string>($@"(directives.ServiceBulletinNo <> '' 
				                                           or directives.ServiceBulletinFileID > 0 
				                                           or directives.DirectiveType = {directiveType.ItemId})"                );
            }
            else
            {
                //state = new CommonFilter<DirectiveType>(Directive.DirectiveTypeProperty, directiveType);
                state =
                    new CommonFilter <string>($@"(directives.Title != 'N/A'
                                                           and directives.DirectiveType = {directiveType.ItemId})");
            }
            return(state);
        }
Esempio n. 20
0
 protected void AssertDirectiveHasFieldsArgument(DirectiveType directive)
 {
     Assert.Collection(directive.Arguments,
                       t =>
     {
         Assert.Equal("fields", t.Name);
         Assert.IsType <FieldSetType>(
             Assert.IsType <NonNullType>(t.Type).Type);
     }
                       );
 }
Esempio n. 21
0
        public SchemaBuilder Include(DirectiveType directiveType)
        {
            if (_directives.ContainsKey(directiveType.Name))
            {
                throw new SchemaBuilderException(directiveType.Name,
                                                 $"Cannot include directive '{directiveType.Name}'. Directive already known.");
            }

            _directives.Add(directiveType.Name, directiveType);
            return(this);
        }
 ///<summary>
 /// Создается объект, описывающий отображение добавления шаблонной директивы
 ///</summary>
 /// <param name="parentAircraft">Родительский объект, в который добавляется шаблонная директива</param>
 /// <param name="directiveType">Тип директивы</param>
 public DispatcheredTemplateDirectiveAdding(TemplateAircraft parentAircraft, DirectiveType directiveType) : this()
 {
     if (parentAircraft == null)
     {
         throw new ArgumentNullException("parentAircraft");
     }
     parentBaseDetail        = parentAircraft;
     this.directiveType      = directiveType;
     aircraftHeader.Aircraft = parentAircraft;
     ClearFields();
 }
Esempio n. 23
0
 /// <summary>
 /// Очищает все поля
 /// </summary>
 public void ClearFields(DirectiveType directiveType)
 {
     if (directiveType == DirectiveTypeCollection.Instance.ADDirectiveType)
     {
         ManhoursString = "";
         CostString     = "";
     }
     Ndt            = false;
     EngOrderNumber = "";
     KitRequired    = "";
 }
Esempio n. 24
0
        ///<summary>
        /// Создает страницу для отображения информации об одной директиве
        ///</summary>
        /// <param name="directive">Директива</param>
        public DirectiveScreen(Directive directive) : this()
        {
            if (directive == null)
            {
                throw new ArgumentNullException("directive", "Argument cannot be null");
            }

            _currentDirective = directive;
            _directiveType    = directive.DirectiveType;

            Initialize();
        }
 ///<summary>
 /// Создается объект, описывающий отображение добавления директивы
 ///</summary>
 /// <param name="parentAircraft">Родительский объект, в который добавляется директива</param>
 /// <param name="directiveType">Тип директивы</param>
 public DispatcheredDirectiveAdding(Aircraft parentAircraft, DirectiveType directiveType)
 {
     if (parentAircraft == null)
     {
         throw new ArgumentNullException("parentAircraft");
     }
     parentBaseDetail   = parentAircraft;
     this.directiveType = directiveType;
     InitializeComponent(directiveType);
     aircraftHeader.Aircraft = parentAircraft;
     ClearFields();
 }
Esempio n. 26
0
        public static List <DbQuery> GetSelectQuery(DirectiveType directiveType, string text,
                                                    string paragraph,
                                                    bool loadChild  = false,
                                                    bool getDeleted = false)
        {
            List <ICommonFilter> allFilters = new List <ICommonFilter> ();

            allFilters.Add(GetWhereStatementForAll(directiveType, text, paragraph));
            List <DbQuery> qrs = BaseQueries.GetSelectQueryWithWhereAll <Directive>(allFilters.ToArray(), loadChild, getDeleted);

            return(qrs);
        }
Esempio n. 27
0
        ///<summary>
        /// Создает страницу для отображения информации об одной директиве
        ///</summary>
        /// <param name="outOfPhase">Директива</param>
        public OutOfPhaseReferenceScreen(Directive outOfPhase) : this()
        {
            if (outOfPhase == null)
            {
                throw new ArgumentNullException("outOfPhase", "Argument cannot be null");
            }

            _directiveType     = outOfPhase.DirectiveType;
            _currentOutOfPhase = outOfPhase;

            Initialize();
        }
Esempio n. 28
0
 ///<summary>
 /// Создается элемент отображения коллекции директив базового агрегата
 ///</summary>
 ///<param name="currentBaseDetail"></param>
 ///<exception cref="ArgumentNullException"></exception>
 ///<param name="viewFilter"></param>
 ///<param name="reportText"></param>
 ///<param name="directiveType"></param>
 public DirectiveListViewer(BaseDetail currentBaseDetail, DirectiveCollectionFilter viewFilter, string reportText, DirectiveType directiveType)
 {
     if (currentBaseDetail == null)
     {
         throw new ArgumentNullException("currentBaseDetail", "Cannot display null-baseDetail");
     }
     this.currentBaseDetail = currentBaseDetail;
     this.viewFilter        = viewFilter;
     this.reportText        = reportText;
     this.directiveType     = directiveType;
     InitializeComponent();
     UpdateElements();
 }
Esempio n. 29
0
        /// <summary>
        /// Возвращает все директивы базового агрегата, самолета, или задачи созданные в рамках страницы бортжурнала
        /// </summary>
        /// <returns></returns>
        private DirectiveCollection GetDirectives(BaseComponent parentBaseComponent,
                                                  Aircraft parentAircraft,
                                                  AircraftFlight parentFlight,
                                                  DirectiveType directiveType)
        {
            if (parentAircraft == null && parentBaseComponent == null && parentFlight == null)
            {
                throw new ArgumentNullException();
            }
            if (directiveType == null)
            {
                directiveType = DirectiveType.AirworthenessDirectives;
            }

            List <DbQuery> qrs;

            if (parentBaseComponent != null)
            {
                qrs = DirectiveQueries.GetSelectQuery(parentBaseComponent, directiveType, loadChild: true);
            }
            else if (parentAircraft != null)
            {
                qrs = DirectiveQueries.GetAircraftDirectivesSelectQuery(parentAircraft.ItemId, directiveType, loadChild: true);
            }
            else
            {
                qrs = DirectiveQueries.GetSelectQuery(parentFlight, directiveType, loadChild: true);
            }

            var directives = new DirectiveCollection();

            directives.AddRange(_loader.GetObjectListAll <Directive>(qrs, true));

            if (directives.Count == 0)
            {
                return(directives);
            }

            var directiveIds   = directives.Select(d => d.ItemId).ToList();
            var itemsRelations = _itemsRelationsDataAccess.GetRelations(directiveIds, SmartCoreType.Directive.ItemId);

            if (itemsRelations.Count > 0)
            {
                foreach (var directive in directives)
                {
                    directive.ItemRelations.AddRange(itemsRelations.Where(i => i.FirstItemId == directive.ItemId || i.SecondItemId == directive.ItemId));
                }
            }

            return(directives);
        }
Esempio n. 30
0
 public static ISchemaError DirectiveCollection_DirectiveIsUnique(
     DirectiveType directiveType,
     ITypeSystemObject type,
     DirectiveNode?syntaxNode,
     object source) =>
 SchemaErrorBuilder.New()
 .SetMessage(
     TypeResources.DirectiveCollection_DirectiveIsUnique,
     directiveType.Name)
 .SetCode(ErrorCodes.Schema.MissingType)
 .SetTypeSystemObject(type)
 .AddSyntaxNode(syntaxNode)
 .SetExtension("Source", source)
 .Build();
        /// <summary>
        /// 预处理:页面,用户控件上的指令
        /// </summary>
        public override void PreprocessDirective(string directiveName, IDictionary attributes)
        {
            base.PreprocessDirective(directiveName, attributes);

            string defaultBaseType = null;

            // If we recognize the directive, keep track of what it was. If we don't recognize
            // the directive then just stop.
            switch (directiveName)
            {
                case "page":
                    _directiveType = DirectiveType.Page;
                    defaultBaseType = typeof(MyBasePage).FullName;
                    break;
                case "control":
                    _directiveType = DirectiveType.UserControl;
                    defaultBaseType = typeof(MyBaseUserControl).FullName;
                    break;
                case "master":
                    _directiveType = DirectiveType.Master;
                    defaultBaseType = typeof(MyBaseMasterPage).FullName;
                    break;
            }

            if (_directiveType == DirectiveType.Unknown)
            {
                // If we're processing an unknown directive (e.g. a register directive), stop processing
                return;
            }

            // Look for an inherit attribute
            string inherits = (string)attributes["inherits"];
            if (!String.IsNullOrEmpty(inherits))
            {
                // If it doesn't look like a generic type, don't do anything special,
                // and let the parser do its normal processing
                if (IsGenericTypeString(inherits))
                {
                    // Remove the inherits attribute so the parser doesn't blow up
                    attributes["inherits"] = defaultBaseType;

                    // Remember the full type string so we can later give it to the ControlBuilder
                    _viewBaseType = inherits;
                }
            }
        }
        public override void PreprocessDirective(string directiveName, IDictionary attributes)
        {
            base.PreprocessDirective(directiveName, attributes);

            string defaultBaseType = null;

            switch (directiveName) {
                case "page":
                    _directiveType = DirectiveType.Page;
                    defaultBaseType = typeof(BasePage).FullName;
                    break;
                case "control":
                    _directiveType = DirectiveType.UserControl;
                    defaultBaseType = typeof(UserControl).FullName;
                    break;
                case "master":
                    _directiveType = DirectiveType.Master;
                    defaultBaseType = typeof(MasterPage).FullName;
                    break;
            }

            if (_directiveType == DirectiveType.Unknown) {
                return;
            }

            var inherits = (string)attributes["inherits"];
            if (!String.IsNullOrEmpty(inherits)) {
                if (IsGenericTypeString(inherits)) {
                    attributes["inherits"] = defaultBaseType;
                    _viewBaseType = inherits;
                }
            }
        }
        public override void PreprocessDirective(string directiveName, IDictionary attributes)
        {
            base.PreprocessDirective(directiveName, attributes);
            string fullName = null;
            
            if (directiveName != null)
            {
                if (directiveName != "page")
                {
                    if (directiveName == "control")
                    {
                        _directiveType = DirectiveType.UserControl;
                        fullName = typeof(ViewUserControl).FullName;
                    }
                    else if (directiveName == "master")
                    {
                        _directiveType = DirectiveType.Master;
                        fullName = typeof(ViewMasterPage).FullName;
                    }
                }
                else
                {
                    _directiveType = DirectiveType.Page;
                    fullName = typeof(ViewPage).FullName;
                }
            }

            if (_directiveType != DirectiveType.Unknown)
            {
                string inherits = (string)attributes["inherits"];
                if (!String.IsNullOrEmpty(inherits) && IsGenericTypeString(inherits))
                {
                    attributes["inherits"] = fullName;
                    _viewBaseType = inherits;
                }
            }
        }
Esempio n. 34
0
 public Directive(DirectiveType type, string parameter)
 {
     Type = type;
     Parameter = parameter;
 }
        /// <summary>
        /// Parses "directive" from specified reader.
        /// </summary>
        /// <param name="reader">Reader from where to parse.</param>
        /// <exception cref="ArgumentNullException">Raised when <b>reader</b> is null.</exception>
        /// <exception cref="SIP_ParseException">Raised when invalid SIP message.</exception>
        public override void Parse(StringReader reader)
        {
            /*
                directive          = proxy-directive / cancel-directive / fork-directive / recurse-directive /
                                     parallel-directive / queue-directive
                proxy-directive    = "proxy" / "redirect"
                cancel-directive   = "cancel" / "no-cancel"
                fork-directive     = "fork" / "no-fork"
                recurse-directive  = "recurse" / "no-recurse"
                parallel-directive = "parallel" / "sequential"
                queue-directive    = "queue" / "no-queue"
            */

            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            // Get Method
            string word = reader.ReadWord();
            if (word == null)
            {
                throw new SIP_ParseException("'directive' value is missing !");
            }
            if (word.ToLower() == "proxy")
            {
                m_Directive = DirectiveType.Proxy;
            }
            else if (word.ToLower() == "redirect")
            {
                m_Directive = DirectiveType.Redirect;
            }
            else if (word.ToLower() == "cancel")
            {
                m_Directive = DirectiveType.Cancel;
            }
            else if (word.ToLower() == "no-cancel")
            {
                m_Directive = DirectiveType.NoCancel;
            }
            else if (word.ToLower() == "fork")
            {
                m_Directive = DirectiveType.Fork;
            }
            else if (word.ToLower() == "no-fork")
            {
                m_Directive = DirectiveType.NoFork;
            }
            else if (word.ToLower() == "recurse")
            {
                m_Directive = DirectiveType.Recurse;
            }
            else if (word.ToLower() == "no-recurse")
            {
                m_Directive = DirectiveType.NoRecurse;
            }
            else if (word.ToLower() == "parallel")
            {
                m_Directive = DirectiveType.Parallel;
            }
            else if (word.ToLower() == "sequential")
            {
                m_Directive = DirectiveType.Sequential;
            }
            else if (word.ToLower() == "queue")
            {
                m_Directive = DirectiveType.Queue;
            }
            else if (word.ToLower() == "no-queue")
            {
                m_Directive = DirectiveType.NoQueue;
            }
            else
            {
                throw new SIP_ParseException("Invalid 'directive' value !");
            }
        }