public void Initialize(ContextBase context, SchemaScope parent, int initialDepth, ScopeType type)
        {
            base.Initialize(context, parent, initialDepth, type);

            ParentSchemaScope = parent;
            ConditionalContext = ConditionalContext.Create(context);
        }
Esempio n. 2
0
		public Category (Tiles.TileGroupInfo info, int columns)
		{
			WidgetFlags |= WidgetFlags.NoWindow;

			header = new Gtk.HBox (false, 0);

			headerExpander = new Gtk.Expander ("<big><b>" + GLib.Markup.EscapeText (info.Name) + "</b></big>");
			((Gtk.Label) headerExpander.LabelWidget).SetAlignment (0.0f, 0.5f);
			headerExpander.UseMarkup = true;
			headerExpander.UseUnderline = true;
			headerExpander.Show ();
			header.PackStart (headerExpander, true, true, 0);

			headerExpander.Activated += OnActivated;
			
			scope = Tiles.Utils.TileGroupToScopeType(info.Group);
			
			position = new Gtk.Label ();
			position.ModifyFg (Gtk.StateType.Normal, position.Style.Base (Gtk.StateType.Selected));
			header.PackStart (position, false, false, 0);
			position.Show ();

			prev = MakeButton (header, Gtk.Stock.GoBack, OnPrev);
			next = MakeButton (header, Gtk.Stock.GoForward, OnNext);

			header.Show ();
			header.Parent = this;
			header.SizeRequested += HeaderSizeRequested;

			tiles = new SortedTileList (Beagle.Search.SortType.Relevance);
			Columns = columns;

			UpdateButtons ();
			Expanded = true;	
		}
        private void RecordEvent(string url, ScopeType scopeType, string key)
        {
            if (!isCollecting)
                return;

            events.Add(new BrowserEvent { ScopeType = scopeType, ScopeKey = key, Page = GetRelativeUrl(url)});
        }
Esempio n. 4
0
 internal Scope(IParameterMetadataProvider ast, ScopeType scopeType)
 {
     _ast = (Ast)ast;
     _scopeType = scopeType;
     _typeTable = new Dictionary<string, TypeLookupResult>(StringComparer.OrdinalIgnoreCase);
     _variableTable = new Dictionary<string, Ast>(StringComparer.OrdinalIgnoreCase);
 }
Esempio n. 5
0
 // Constructor
 public Symbol(string name, ScopeType scope)
 {
     Name = name;
     Scope = scope;
     Frequency = 0;
     ConstAllowed = true;
     Accessibility= Accessibility.Default;
 }
Esempio n. 6
0
 protected void Initialize(ContextBase context, Scope parent, int initialDepth, ScopeType type)
 {
     Context = context;
     Parent = parent;
     InitialDepth = initialDepth;
     Type = type;
     Complete = false;
 }
Esempio n. 7
0
 // Copy constructor
 public Symbol(Symbol other)
 {
     Name = other.Name;
     Scope = other.Scope;
     Frequency = other.Frequency;
     Rank = other.Rank;
     Accessibility = other.Accessibility;
     ConstAllowed = false;
 }
Esempio n. 8
0
 public ScopeMetaInformation(String name, ScopeType scopeType)
 {
     this.name = name;
     this.scopeType = scopeType;
     forCount = 0;
     ifCount = 0;
     computationCount = 0;
     inSubgraphCount = 0;
 }
Esempio n. 9
0
        public Scope(ScopeType scopeType, string name, Scope enclosingScope)
        {
            Debug.Assert(name != null && name != "");
            Debug.Assert(enclosingScope != null);

            m_scopeType = scopeType;
            m_name = name;
            m_enclosingScope = enclosingScope;
        }
Esempio n. 10
0
        public string GetOpenUrl(string redirectUri, ScopeType scope, string state)
        {
            if (!ConfigGlobal_Arsenal.WeChatActive) { return null; }

            //https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&state=STATE#wechat_redirect

            var serverUrl = "https://open.weixin.qq.com/connect/oauth2/";

            return $"{serverUrl}authorize?appid={AppKey}&redirect_uri={HttpUtility.UrlEncode(redirectUri, Encoding.UTF8)}&response_type=code&scope={scope}&state={HttpUtility.UrlEncode(state, Encoding.UTF8)}#wechat_redirect";
        }
    private string ScopeTypeToString(ScopeType scope)
    {
      var enumNamesMap = new Dictionary<ScopeType, string>();
      enumNamesMap.Add(ScopeType.Parent, "p");
      enumNamesMap.Add(ScopeType.Self, "s");
      enumNamesMap.Add(ScopeType.Children, "c");

      string result = enumNamesMap[scope];
      return result;
    }
Esempio n. 12
0
        public Dictionary<int, List<AttributeInfoType>> getAttributeScope(ScopeType type)
        {
            Dictionary<int, List<AttributeInfoType>> ret=new Dictionary<int, List<AttributeInfoType>>();

            if(mAttributeScopes.ContainsKey((int)type))
            {
                ret.Add((int)type, mAttributeScopes[(int)type]);
            }
            return ret;
        }
Esempio n. 13
0
 public TablePromptType()
 {
     this.Scope         = ScopeType.Local;
     this.Width         = double.NaN;
     this.Height        = double.NaN;
     this.LabelPosition = LabelPositionType.Auto;
     this.Source        = SourceType.ItemsList;
     this.AllowAdd      = true;
     this.AllowRemove   = true;
     this.AllowModify   = true;
 }
Esempio n. 14
0
        public void CreateRegionWithTallyWriter(ScopeType scope)
        {
            AttributesFactory af = new AttributesFactory();

            af.SetCacheWriter(m_lwr);
            af.SetScope(scope);
            af.SetCachingEnabled(true);

            m_netWriteRegion = CacheHelper.CreateRegion(TestRegionWrite,
                                                        af.CreateRegionAttributes());
        }
Esempio n. 15
0
        internal void OpenLocalScope(ScopeType scopeType = ScopeType.Variable, Cci.ITypeReference exceptionType = null)
        {
            if (scopeType == ScopeType.TryCatchFinally && IsJustPastLabel())
            {
                DefineHiddenSequencePoint();
                EmitOpCode(ILOpCode.Nop);
            }

            if (scopeType == ScopeType.Finally)
            {
                // WORKAROUND:
                // This is a workaround to an unexpected consequence of a CLR update that causes try nested in finally not verify
                // if there is no code before try. ( DevDiv: 563799 )
                // If we will treat finally as a label, the code above will force a nop before try starts.
                _instructionCountAtLastLabel = _emitState.InstructionsEmitted;
            }

            EndBlock();  //blocks should not cross scope boundaries.
            var scope = _scopeManager.OpenScope(scopeType, exceptionType);

            // Exception handler scopes must have a leader block, even
            // if the exception handler is empty, and created before any
            // other block (before nested scope blocks in particular).
            switch (scopeType)
            {
            case ScopeType.Try:
                Debug.Assert(!_pendingBlockCreate);
                _pendingBlockCreate = true;
                break;

            case ScopeType.Catch:
            case ScopeType.Filter:
            case ScopeType.Finally:
            case ScopeType.Fault:
                Debug.Assert(!_pendingBlockCreate);
                _pendingBlockCreate = true;

                // this is the actual start of the handler.
                // since it is reachable by an implicit jump (via exception handling)
                // we need to put a hidden point to ensure that debugger does not associate
                // this location with some previous sequence point
                DefineHiddenSequencePoint();

                break;

            case ScopeType.Variable:
            case ScopeType.TryCatchFinally:
            case ScopeType.StateMachineVariable:
                break;

            default:
                throw ExceptionUtilities.UnexpectedValue(scopeType);
            }
        }
Esempio n. 16
0
 public ScopeBlock(ScopeType type, ExceptionHandler eh)
 {
     if (type == ScopeType.None)
     {
         throw new ArgumentException("type");
     }
     this.Type             = type;
     this.ExceptionHandler = eh;
     this.Children         = new List <ScopeBlock>();
     this.Content          = new List <IBasicBlock>();
 }
Esempio n. 17
0
 public Tree ParseBlockOrStatement(ScopeType type)
 {
     if (accept(lCurly).valid)
     {
         return(ParseBlock(type, rCurly));
     }
     else
     {
         return(ParseStatement());
     }
 }
Esempio n. 18
0
        public void PushScope(ScopeType scopeType)
        {
            // initial scopes of type Globals and Sequence must be handled by PushFirstScope
            Debug.Assert(scopes.Count > 1);
            Debug.Assert(scopesMeta.Count > 1);

            scopes.Push(new Dictionary <String, SequenceVariable>());

            String scopeName;

            switch (scopeType)
            {
            case ScopeType.For:
                scopeName = "for" + scopesMeta.Peek().forCount;
                ++scopesMeta.Peek().forCount;
                break;

            case ScopeType.If:
                scopeName = "if" + scopesMeta.Peek().ifCount;
                ++scopesMeta.Peek().ifCount;
                break;

            case ScopeType.IfThenPart:
                scopeName = "thenpart";
                break;

            case ScopeType.Backtrack:
                scopeName = "backrack" + scopesMeta.Peek().backtrackCount;
                ++scopesMeta.Peek().backtrackCount;
                break;

            case ScopeType.ForRulePrefixedSequence:
                scopeName = "ruleprefixedsequence" + scopesMeta.Peek().rulePrefixedSequenceCount;
                ++scopesMeta.Peek().rulePrefixedSequenceCount;
                break;

            case ScopeType.Computation:
                scopeName = "computation" + scopesMeta.Peek().computationCount;
                ++scopesMeta.Peek().computationCount;
                break;

            case ScopeType.InSubgraph:
                scopeName = "insubgraph" + scopesMeta.Peek().inSubgraphCount;
                ++scopesMeta.Peek().inSubgraphCount;
                break;

            default:
                Debug.Assert(false); // only first scopes can be of type Globals and Sequence
                scopeName = "";
                break;
            }

            scopesMeta.Push(new ScopeMetaInformation(scopeName, scopeType));
        }
Esempio n. 19
0
 public ScopeMetaInformation(String name, ScopeType scopeType)
 {
     this.name                 = name;
     this.scopeType            = scopeType;
     forCount                  = 0;
     ifCount                   = 0;
     backtrackCount            = 0;
     rulePrefixedSequenceCount = 0;
     computationCount          = 0;
     inSubgraphCount           = 0;
 }
Esempio n. 20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CreateWebScopeSettings" /> class.
 /// </summary>
 /// <param name="restrictParentUrl">restrictParentUrl.</param>
 /// <param name="scopeType">scopeType.</param>
 /// <param name="useTitleInUrl">useTitleInUrl.</param>
 /// <param name="enableUrlValidation">enableUrlValidation.</param>
 /// <param name="textValidationRule">textValidationRule.</param>
 /// <param name="selectedNodes">selectedNodes.</param>
 /// <param name="autoPopulateUrlWithSPContext">autoPopulateUrlWithSPContext.</param>
 /// <param name="autoPopulateUrlWithSPContextAssignBy">autoPopulateUrlWithSPContextAssignBy.</param>
 public CreateWebScopeSettings(string restrictParentUrl = default(string), ScopeType scopeType = default(ScopeType), bool useTitleInUrl = default(bool), bool enableUrlValidation = default(bool), TextValidationRuleRef textValidationRule = default(TextValidationRuleRef), List <SPNode> selectedNodes = default(List <SPNode>), bool autoPopulateUrlWithSPContext = default(bool), AssignBy autoPopulateUrlWithSPContextAssignBy = default(AssignBy))
 {
     this.RestrictParentUrl                    = restrictParentUrl;
     this.ScopeType                            = scopeType;
     this.UseTitleInUrl                        = useTitleInUrl;
     this.EnableUrlValidation                  = enableUrlValidation;
     this.TextValidationRule                   = textValidationRule;
     this.SelectedNodes                        = selectedNodes;
     this.AutoPopulateUrlWithSPContext         = autoPopulateUrlWithSPContext;
     this.AutoPopulateUrlWithSPContextAssignBy = autoPopulateUrlWithSPContextAssignBy;
 }
Esempio n. 21
0
        internal ScopeInfo OpenScope(ScopeType type, ShaderType tInfo = null, ISegmentTracker tracker = null)
        {
            ScopeInfo newScope = Pooling.Scopes.Get();

            newScope.Parent           = _currentScope;
            newScope.IndentationDepth = _currentScope.IndentationDepth + 1;
            newScope.Type             = type;
            newScope.TypeInfo         = tInfo;
            newScope.Settings         = ScopeSettings.Settings[type];

            // Track namespace path
            if ((type == ScopeType.Class || type == ScopeType.Struct) && tInfo != null)
            {
                newScope.Namespace = $"{_currentScope.Namespace}+{tInfo.OriginalType.Name}";
            }
            else
            {
                newScope.Namespace = _currentScope.Namespace;
            }

            _scopes.Push(_currentScope); // Push old scope
            _currentScope = newScope;    // Set new as current

            if ((_currentScope.Settings.OpeningSyntax.NewLine & NewLineFlags.Before) == NewLineFlags.Before)
            {
                newScope.OpeningSegment = AppendLineBreak();
            }

            if (!string.IsNullOrEmpty(_currentScope.Settings.OpeningSyntax.Value))
            {
                newScope.OpeningSegment = Append(_currentScope.Settings.OpeningSyntax.Value);
            }

            if ((_currentScope.Settings.OpeningSyntax.NewLine & NewLineFlags.After) == NewLineFlags.After)
            {
                newScope.OpeningSegment = AppendLineBreak();
            }

            newScope.OpeningSegment         = newScope.OpeningSegment ?? Append("");
            newScope.OpeningSegment.Scope   = ScopeMode.Opening;
            newScope.OpeningSegment.Tracker = tracker;

            if (tracker != null)
            {
                tracker.StartIndex = 5;
            }

            if (newScope.Settings.Indent)
            {
                newScope.OpeningSegment.Indentation = IndentMode.Increment;
            }

            return(newScope);
        }
Esempio n. 22
0
        public void CreateRegionWithTallyLoader(ScopeType scope)
        {
            AttributesFactory af = new AttributesFactory();

            af.SetCacheLoader(m_ldr);
            af.SetScope(scope);
            af.SetCachingEnabled(true);

            m_region = CacheHelper.CreateRegion(TestRegion,
                                                af.CreateRegionAttributes());
        }
Esempio n. 23
0
 protected override bool IsValidConditionalValidation(ScopeType scopeType, List <string> ErrorMessageList, string Path)
 {
     if (string.IsNullOrWhiteSpace(this.Value))
     {
         if (this.ChildResultList is null)
         {
             ErrorMessageList.Add($"The result value found at {Path} can not be null or empty unless the result has children results set in the {nameof(this.ChildResultList)}.");
         }
     }
     return(ErrorMessageList.Count() == 0);
 }
Esempio n. 24
0
        public Scope BeginNewScope(ScopeType type)
        {
            var scope = new Scope(Context, this);

            if (type == ScopeType.Block)
            {
                scope.Type = Type | type;
            }

            return(scope);
        }
    public bool AddScope(ScopeType scope)
    {
      if (this.accumulatedScope.Contains(scope))
      {
        return false;
        //        throw new InvalidOperationException("Adding scope parameter duplicates is forbidden");
      }

      this.accumulatedScope.Add(scope);
      return true;
    }
Esempio n. 26
0
            protected override IUnitOfWork CreateUnitOfWork(ScopeType scopeType)
            {
                var unitOfWork = Substitute.For <IUnitOfWork>();

                unitOfWork.ScopeType.Returns(scopeType);
                unitOfWork.When(x => x.Dispose())
                .Do(x => Remove(unitOfWork));
                unitOfWork.When(x => x.Commit())
                .Do(x => Complete(unitOfWork));
                return(unitOfWork);
            }
Esempio n. 27
0
 protected override bool IsValidConditionalValidation(ScopeType scopeType, List <string> ErrorMessageList, string Path)
 {
     if (this.Type == IdentifierType.MRN && scopeType == ScopeType.Hl7v2)
     {
         if (string.IsNullOrWhiteSpace(this.AssigningAuthority))
         {
             ErrorMessageList.Add($"It is a conditional requirement that is the {nameof(this.AssigningAuthority)} must be set to a value when the {nameof(this.Type)} is set to {this.Type.ToString()}. The {nameof(this.AssigningAuthority)} was found to be null or empty at the following path:  {Path}");
         }
     }
     return(ErrorMessageList.Count == 0);
 }
Esempio n. 28
0
        public void CreateRegionWithTallyLoader(ScopeType scope)
        {
            var regionAttributesFactory = new RegionAttributesFactory();

            regionAttributesFactory.SetCacheLoader(m_ldr);
            regionAttributesFactory.SetScope(scope);
            regionAttributesFactory.SetCachingEnabled(true);

            m_region = CacheHelper.CreateRegion(TestRegion,
                                                regionAttributesFactory.Create());
        }
Esempio n. 29
0
 public ListBoxPromptType()
 {
     this.Scope = ScopeType.Local;
     this.SaveLastInputAsDefault = SaveLastInputAsDefaultType.None;
     this.Width             = double.NaN;
     this.Height            = double.NaN;
     this.LabelPosition     = LabelPositionType.Auto;
     this.ItemValueMember   = "Value";
     this.ItemDisplayMember = "Value";
     this.Source            = SourceType.ItemsList;
     this.MultiValue        = false;
 }
        private string ScopeTypeToString(ScopeType scope)
        {
            var enumNamesMap = new Dictionary <ScopeType, string>();

            enumNamesMap.Add(ScopeType.Parent, "p");
            enumNamesMap.Add(ScopeType.Self, "s");
            enumNamesMap.Add(ScopeType.Children, "c");

            string result = enumNamesMap[scope];

            return(result);
        }
Esempio n. 31
0
        /// <summary>
        /// 解释Contains条件
        /// </summary>
        /// <param name="list"></param>
        /// <param name="entityType"></param>
        /// <param name="paramName"></param>
        /// <param name="type"></param>
        /// <param name="lstIndex"></param>
        public static string Contains(Scope scope, ParamList list, Type entityType, string paramName, DbType type, int lstIndex)
        {
            DBInfo        db            = EntityInfoManager.GetEntityHandle(entityType).DBInfo;
            string        paramVal      = db.CurrentDbAdapter.FormatValueName(DataAccessCommon.FormatParam(paramName, lstIndex));
            string        paramKey      = db.CurrentDbAdapter.FormatParamKeyName(DataAccessCommon.FormatParam(paramName, lstIndex));
            StringBuilder sql           = new StringBuilder(500);
            ScopeType     ctype         = scope.ScopeType;
            string        connectString = DataAccessCommon.GetConnectString(scope);

            sql.Append(FullTextConfigManager.GetLikeSql(scope, list, paramName, type, lstIndex, entityType, connectString, true));
            return(sql.ToString());
        }
Esempio n. 32
0
 protected override bool IsValidConditionalValidation(ScopeType scopeType, List <string> ErrorMessageList, string Path)
 {
     if (scopeType == ScopeType.Cda)
     {
         //Check we have a HPI-I for the reporting Pathologist
         if (!this.ReportingPathologist.IdentifierList.Any(x => x.Type == IdentifierType.HPII))
         {
             ErrorMessageList.Add($"All {nameof(this.ReportingPathologist)}s must have an identifier of type {IdentifierType.HPII.ToString()}");
         }
     }
     return(ErrorMessageList.Count() == 0);
 }
Esempio n. 33
0
        public void ScopeTypeController_DeleteScopeType_Throws_On_Negative_ScopeTypeId()
        {
            // Arrange
            var mockDataService     = new Mock <IDataService>();
            var scopeTypeController = new ScopeTypeController(mockDataService.Object);

            ScopeType scopeType = ContentTestHelper.CreateValidScopeType();

            scopeType.ScopeTypeId = Null.NullInteger;

            Assert.Throws <ArgumentOutOfRangeException>(() => scopeTypeController.DeleteScopeType(scopeType));
        }
Esempio n. 34
0
        public bool hasOneOfElementsInScope(ScopeType type, params string[] tagNames)
        {
            foreach (var item in tagNames)
            {
                if (hasElementInScope(item, type))
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 35
0
        public void ScopeTypeController_UpdateScopeType_Throws_On_Negative_ScopeTypeId()
        {
            // Arrange
            var mockDataService     = new Mock <IDataService>();
            var scopeTypeController = new ScopeTypeController(mockDataService.Object);

            ScopeType scopeType = ContentTestHelper.CreateValidScopeType();

            scopeType.ScopeType = Constants.SCOPETYPE_InValidScopeType;

            Assert.Throws <ArgumentOutOfRangeException>(() => scopeTypeController.UpdateScopeType(scopeType));
        }
Esempio n. 36
0
        /// <summary>
        /// Creates a new instance of <see cref="Scope"/> using the
        /// specified parent <see cref="Scope"/> and attachment
        /// </summary>
        /// <param name="parentScope">The parent Scope that this Scope falls under</param>
        /// <param name="type">The method of attachment to our parent.</param>
        public Scope(Scope parentScope, ScopeType type)
        {
            // parentScope cannot be null if we are attached!
            if (parentScope == null && type == ScopeType.Attached)
            {
                throw new ArgumentNullException("parentScope",
                                                "Parent scope must be defined when using ScopeType.Attached!"
                                                );
            }

            // Set internals
            ParentScope = parentScope;
            ScopeType   = type;

            // Get our active objects, if any
            if (ScopeType == ScopeType.Attached)
            {
                // Just use the parent's reference
                ActiveObjects = ParentScope.ActiveObjects;

                // Create new references because what is added to this Scope, should
                // NOT be added to the parents scope as well!!!
                var c = new ObjectEqualityComparer();
                Objects     = new Dictionary <Tuple <string, ReferenceType>, ConFileObject>(ParentScope.Objects, c);
                Expressions = new Dictionary <string, Expression>(ParentScope.Expressions);
            }
            else
            {
                // Create new instances
                var c = new ObjectEqualityComparer();
                ActiveObjects = new Dictionary <ReferenceType, ConFileObject>();
                Objects       = new Dictionary <Tuple <string, ReferenceType>, ConFileObject>(c);
                Expressions   = new Dictionary <string, Expression>();

                // Copy over the active objects from our parent
                if (ParentScope != null)
                {
                    // Perform a deep copy since we are Detached
                    foreach (var item in ParentScope.ActiveObjects)
                    {
                        try
                        {
                            ActiveObjects[item.Key] = item.Value.Clone();
                        }
                        catch
                        {
                            throw;
                        }
                    }
                }
            }
        }
 public LocalScope(string name, ScopeType type, LocalScope parent = null, LocalScope child = null)
 {
     this.name = name;
     if (parent != null)
     {
         this.parent = parent;
     }
     if (child != null)
     {
         this.child = child;
     }
     this.type = type;
 }
Esempio n. 38
0
        public virtual void Initialize(ContextBase context, SchemaScope parent, int initialDepth, ScopeType type)
        {
            Context      = context;
            Parent       = parent;
            InitialDepth = initialDepth;
            Type         = type;
            Complete     = false;

#if DEBUG
            Interlocked.Increment(ref LastDebugId);
            DebugId = LastDebugId;
#endif
        }
Esempio n. 39
0
 public T GetCachedScope <T>(ScopeType type) where T : Scope
 {
     for (int i = 0; i < _scopesCache.Count; i++)
     {
         Scope s = _scopesCache[i];
         if (s.Type == type)
         {
             _scopesCache.RemoveAt(i);
             return((T)s);
         }
     }
     return(null);
 }
        private static void VerifyPermissionType(PermissionType permission)
        {
            Assert.NotNull(permission);

            Assert.NotNull(permission.SchemeName);
            Assert.Equal("scheme name", permission.SchemeName);

            Assert.NotNull(permission.Scopes);
            ScopeType scope = Assert.Single(permission.Scopes);

            Assert.Equal("scope name", scope.Scope);
            Assert.Null(scope.RestrictedProperties);
        }
Esempio n. 41
0
 public ConfigScope(ScopeType type, string moduleName, ModuleConfigSpec spec)
     : base(type, moduleName)
 {
     Field            = spec.Binding?.Field;
     IgnoreCase       = spec.Binding?.IgnoreCase;
     NameSeparator    = spec?.Binding?.NameSeparator;
     TargetName       = spec.Binding?.TargetName;
     TargetType       = spec.Binding?.TargetType;
     UseQualifiedName = spec.Binding?.UseQualifiedName;
     Culture          = spec.Output?.Culture;
     Configuration    = spec.Configuration != null ?
                        new Dictionary <string, object>(spec.Configuration, StringComparer.OrdinalIgnoreCase) : new Dictionary <string, object>(StringComparer.OrdinalIgnoreCase);
 }
Esempio n. 42
0
 private void PutComma(ScopeType scopeType)
 {
     if (scopes.Count != 0)
     {
         Scope currentScope = scopes.Peek();
         if (currentScope.Type == scopeType &&
             currentScope.ObjectCount != 0)
         {
             writer.Write(',');
         }
         currentScope.ObjectCount++;
     }
 }
Esempio n. 43
0
        public Scope(Scope outter, ScopeType type, TokenPos pos)
        {
            if (outter != null)
            {
                outter._child.Add(this);
            }

            _outter = outter;

            _type = type;

            _defpos = pos;
        }
        /// <summary>
        /// Create data on the server which can be retrieved later. For use when build custom outside processes and for some custom SQL filters on controls, such as the Document List and Form Data controls, which will replace tokens with a serialized Dictionary converted to JSON. See VisualVault's online help for more information.
        /// </summary>
        /// <param name="uniqueName">Can be an empty string. If a name is given, it must be unique to the scope. Used to retrieve data by name instead of by ID.</param>
        /// <param name="dataScope">User scope: Only the current user will have access. Global scope: all users have access.</param>
        /// <param name="data">Data to post. For objects, you may want to post them as JSON.</param>
        /// <param name="dataMimeType">For your own use. Indicates what format the data is in, such as text/xml or text/json</param>
        /// <param name="linkedObjectId">Not required. </param>
        /// <param name="linkedObjectType">Can be LinkedObjectType.None. Used to help indicate what object this item is dependent on. For example, if it is linked to a search, when that search ID is deleted (indicated by the linkedObjectId), this data will also be deleted.</param>
        /// <param name="expirationDateUtc">Can be null for never expires. The expiration date of the data after which a background service will remove the data from VisualVault.</param>
        /// <returns></returns>
        public PersistedClientData CreateData(string uniqueName, ScopeType dataScope, string data, string dataMimeType, string linkedObjectId, LinkedObjectType linkedObjectType, DateTime? expirationDateUtc)
        {
            dynamic postData = new ExpandoObject();
            postData.Name = uniqueName;
            postData.Scope = (int)dataScope;
            postData.PersistedData = data;
            postData.DataMimeType = dataMimeType;
            postData.LinkedObjectId = linkedObjectId;
            postData.LinkedObjectType = (int)linkedObjectType;
            postData.ExpirationDateUtc = expirationDateUtc;

            return HttpHelper.Post<PersistedClientData>(VVRestApi.GlobalConfiguration.Routes.PersistedData, string.Empty, GetUrlParts(), this.ClientSecrets, this.ApiTokens, postData);
        }
        public static bool IncludesAllClaimsForUserRule(this IEnumerable<Scope> scopes, ScopeType type)
        {
            foreach (var scope in scopes)
            {
                if (scope.Type == type)
                {
                    if (scope.IncludeAllClaimsForUser)
                    {
                        return true;
                    }
                }
            }

            return false;
        }
Esempio n. 46
0
 private void StartScope(ScopeType type)
 {
     if (this.scopes.Count != 0)
     {
         Scope scope = this.scopes.Peek();
         if ((scope.Type == ScopeType.Array) && (scope.ObjectCount != 0))
         {
             this.writer.Write(",");
         }
         scope.ObjectCount++;
     }
     Scope item = new Scope(type);
     this.scopes.Push(item);
     this.writer.Write((type == ScopeType.Array) ? "[" : "{");
     this.writer.IncreaseIndentation();
     this.writer.WriteLine();
 }
Esempio n. 47
0
 internal Scope(TypeDefinitionAst typeDefinition)
 {
     _ast = typeDefinition;
     _scopeType = ScopeType.Type;
     _typeTable = new Dictionary<string, TypeLookupResult>(StringComparer.OrdinalIgnoreCase);
     _variableTable = new Dictionary<string, Ast>(StringComparer.OrdinalIgnoreCase);
     foreach (var member in typeDefinition.Members)
     {
         var propertyMember = member as PropertyMemberAst;
         if (propertyMember != null)
         {
             // Duplicate members are an error, but we catch that later after all types
             // have been resolved.  We could report errors for properties here, but
             // we couldn't compare methods because overloads can't be compared until types
             // are resolved.
             if (!_variableTable.ContainsKey(propertyMember.Name))
             {
                 _variableTable.Add(propertyMember.Name, propertyMember);
             }
         }
     }
 }
Esempio n. 48
0
		public void PushScope(ScopeType scopeType)
		{
            // initial scopes of type Globals and Sequence must be handled by PushFirstScope
            Debug.Assert(scopes.Count > 1); 
            Debug.Assert(scopesMeta.Count > 1);

            scopes.Push(new Dictionary<String, SequenceVariable>());

            String scopeName;
            switch (scopeType)
            {
                case ScopeType.For:
                    scopeName = "for" + scopesMeta.Peek().forCount;
                    ++scopesMeta.Peek().forCount;
                    break;
                case ScopeType.If:
                    scopeName = "if" + scopesMeta.Peek().ifCount;
                    ++scopesMeta.Peek().ifCount;
                    break;
                case ScopeType.IfThenPart:
                    scopeName = "thenpart";
                    break;
                case ScopeType.Computation:
                    scopeName = "computation" + scopesMeta.Peek().computationCount;
                    ++scopesMeta.Peek().computationCount;
                    break;
                case ScopeType.InSubgraph:
                    scopeName = "insubgraph" + scopesMeta.Peek().inSubgraphCount;
                    ++scopesMeta.Peek().inSubgraphCount;
                    break;
                default:
                    Debug.Assert(false); // only first scopes can be of type Globals and Sequence
                    scopeName = "";
                    break;
            }

            scopesMeta.Push(new ScopeMetaInformation(scopeName, scopeType));
		}
Esempio n. 49
0
        //
        // GET: /Account/WeChatLogin
        public ActionResult WeChatLogin(ScopeType scope)
        {
            var user = UserDto.GetSession();

            if (HttpContext.Request.Url != null)
            {
                var client = new WeChatSnsClient();

                var openUri = client.GetOpenUrl($"http://{HttpContext.Request.Url.Host}/Account/WeChatAuth", scope, user.ID.ToString());

                if (!string.IsNullOrEmpty(openUri))
                {
                    TempData["DataUrl"] = $"data-url={openUri}";
                    return Redirect(openUri);
                }
            }

            TempData["DataUrl"] = "data-url=/Account";
            return RedirectToAction("Index", "Account");
        }
Esempio n. 50
0
 private void PushScope(ScopeType newScopeType)
 {
     this.scopes.Push(new Scope(newScopeType));
 }
Esempio n. 51
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="type">The type of the scope.</param>
 public Scope(ScopeType type)
 {
     this.type = type;
 }
Esempio n. 52
0
        /// <summary>
        /// Start the scope given the scope type.
        /// </summary>
        /// <param name="type">The scope type to start.</param>
        private void StartScope(ScopeType type)
        {
            if (this.scopes.Count != 0)
            {
                Scope currentScope = this.scopes.Peek();
                if ((currentScope.Type == ScopeType.Array) &&
                    (currentScope.ObjectCount != 0))
                {
                    this.writer.Write(JsonConstants.ArrayElementSeparator);
                }

                currentScope.ObjectCount++;
            }

            Scope scope = new Scope(type);
            this.scopes.Push(scope);

            if (type == ScopeType.Array)
            {
                this.writer.Write(JsonConstants.StartArrayScope);
            }
            else
            {
                this.writer.Write(JsonConstants.StartObjectScope);
            }

            this.writer.IncreaseIndentation();
            this.writer.WriteLine();
        }
Esempio n. 53
0
 public Scope(ScopeType scopeType, string name)
 {
     m_scopeType = scopeType;
     m_name = name;
     nrOfScopesInMemory++;
 }
Esempio n. 54
0
 public Scope(ScopeType scopeType, string name)
 {
     m_scopeType = scopeType;
     m_name = name;
 }
			public Scope(ScopeType type)
			{
				_type = type;
			}
		private void StartScope(ScopeType type)
		{
			if (_scopes.Count != 0)
			{
				Scope currentScope = _scopes.Peek();
				if ((currentScope.Type == ScopeType.Array) &&
						(currentScope.ObjectCount != 0))
				{
					_writer.WriteTrimmed(", ");
				}

				currentScope.ObjectCount++;
			}

			Scope scope = new Scope(type);
			_scopes.Push(scope);

			if (type == ScopeType.Array)
			{
				_writer.Write("[");
			}
			else
			{
				_writer.Write("{");
			}
			_writer.Indent++;
			_writer.WriteLine();
		}
Esempio n. 57
0
        internal void OpenLocalScope(ScopeType scopeType = ScopeType.Variable, Cci.ITypeReference exceptionType = null)
        {
            if (scopeType == ScopeType.TryCatchFinally && IsJustPastLabel())
            {
                DefineHiddenSequencePoint();
                EmitOpCode(ILOpCode.Nop);
            }

            if (scopeType == ScopeType.Finally)
            {
                // WORKAROUND:
                // This is a workaround to an unexpected consequence of a CLR update that causes try nested in finally not verify
                // if there is no code before try. ( DevDiv: 563799 )
                // If we will treat finally as a label, the code above will force a nop before try starts.
                _instructionCountAtLastLabel = _emitState.InstructionsEmitted;
            }

            EndBlock();  //blocks should not cross scope boundaries.
            var scope = _scopeManager.OpenScope(scopeType, exceptionType);

            // Exception handler scopes must have a leader block, even
            // if the exception handler is empty, and created before any
            // other block (before nested scope blocks in particular).
            switch (scopeType)
            {
                case ScopeType.Try:
                    Debug.Assert(!_pendingBlockCreate);
                    _pendingBlockCreate = true;
                    break;

                case ScopeType.Catch:
                case ScopeType.Filter:
                case ScopeType.Finally:
                case ScopeType.Fault:
                    Debug.Assert(!_pendingBlockCreate);
                    _pendingBlockCreate = true;

                    // this is the actual start of the handler.
                    // since it is reachable by an implicit jump (via exception handling) 
                    // we need to put a hidden point to ensure that debugger does not associate
                    // this location with some previous sequence point
                    DefineHiddenSequencePoint();

                    break;
                case ScopeType.Variable:
                case ScopeType.TryCatchFinally:
                case ScopeType.StateMachineVariable:
                    break;
                default:
                    throw ExceptionUtilities.UnexpectedValue(scopeType);
            }
        }
Esempio n. 58
0
        public static UserWeChat Authorize(Guid userGuid, string accessToken, double expiresIn, string refreshToken,
            string openId, ScopeType scope, bool anonymous = false)
        {
            using (var conn = new SqlConnection(DataAccess.ConnectString))
            {
                conn.Open();
                var trans = conn.BeginTransaction();

                try
                {
                    IRepository repo = new Repository();

                    // 保存微信用户
                    var user = anonymous ? repo.Single<User>(userGuid) : UserDto.GetSession();

                    if (user != null && user.ID == userGuid)
                    {
                        var u = new UserWeChat();

                        if (repo.Any<UserWeChat>(userGuid))
                        {
                            u = repo.Single<UserWeChat>(userGuid);
                        }

                        u.ID = userGuid;
                        u.UserName = user.UserName;
                        u.LastAuthorizeDate = DateTime.Now;

                        u.AccessToken = accessToken;
                        u.AccessTokenExpiredDate = DateTime.Now.AddSeconds(expiresIn);
                        u.RefreshToken = refreshToken;
                        u.RefreshTokenExpiredDate = DateTime.Now.AddDays(30);

                        u.Gender = 0;

                        if (u.Province == null) u.Province = string.Empty;
                        if (u.City == null) u.City = string.Empty;
                        if (u.Country == null) u.Country = string.Empty;
                        if (u.HeadImgUrl == null) u.HeadImgUrl = string.Empty;
                        if (u.Privilege == null) u.Privilege = string.Empty;
                        if (u.UnionID == null) u.UnionID = string.Empty;

                        repo.Save(u, trans);

                        // 更新普通用户
                        user.WeChatOpenID = openId;

                        // 按scope,获取微信用户详情
                        if (scope.Equals(ScopeType.snsapi_userinfo))
                        {
                            var result = new WeChatSnsClient().GetUserInfo(accessToken, openId);

                            if (!string.IsNullOrEmpty(result))
                            {
                                var json = JToken.Parse(result);

                                user.WeChatNickName = json["nickname"].Value<string>();

                                u.Gender = json["sex"].Value<short>();
                                u.Province = json["province"].Value<string>();
                                u.City = json["city"].Value<string>();
                                u.Country = json["country"].Value<string>();
                                u.HeadImgUrl = json["headimgurl"].Value<string>();
                                u.Privilege = json["privilege"].Value<JArray>().ToString();
                                u.UnionID = json["unionid"] != null ? json["unionid"].Value<string>() : string.Empty;

                                repo.Update(u, trans);
                            }
                        }

                        // 更新user的openId, nickname
                        repo.Update(user, trans);

                        trans.Commit();

                        return u;
                    }

                    return null;
                }
                catch
                {
                    trans.Rollback();

                    throw;
                }
            }
        }
Esempio n. 59
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="type">The type of the scope.</param>
 public Scope(ScopeType type)
 {
     this.type = type;
     switch (type)
     {
         case ScopeType.Array:
             this.StartString = JsonConstants.StartArrayScope;
             this.EndString = JsonConstants.EndArrayScope;
             break;
         case ScopeType.Object:
             this.StartString = JsonConstants.StartObjectScope;
             this.EndString = JsonConstants.EndObjectScope;
             break;
         case ScopeType.Padding:
             this.StartString = JsonConstants.StartPaddingFunctionScope;
             this.EndString = JsonConstants.EndPaddingFunctionScope;
             break;
     }
 }
Esempio n. 60
0
 public IAclEntry AddEntry(AclPermission permission, ScopeType scopeType, params string[] scopeParameters)
 {
     var entry = new AclEntry(permission, ScopeBuilder.CreateScope(scopeType, scopeParameters));
     _entries.Add(entry);
     return entry;
 }