예제 #1
0
 /// <summary>
 /// returns true if the name is in canonical Form
 /// </summary>
 /// <returns></returns>
 public bool IsCanonical()
 {
     return(CanonicalName.IsCanonical(this.Name));
 }
예제 #2
0
        /// <summary>
        /// returns true if this a Data Object class
        /// </summary>
        /// <returns></returns>
        bool IsDataObjectEntry(string name, RuleContext context)
        {
            // check the name might be a full name
            CanonicalName aName       = new CanonicalName(name);
            string        aClassname  = aName.IsCanonical() ? aName.ClassName() : String.Empty;
            string        anEntryName = aName.EntryName();

            // if we are in the right context
            if (context is DataObjectEntryNameContext)
            {
                DataObjectEntryNameContext ctx = (DataObjectEntryNameContext)context;
                if (string.IsNullOrEmpty(ctx.ClassName))
                {
                    aClassname = GetDefaultClassName(context);
                }
                else if (!String.IsNullOrWhiteSpace(ctx.ClassName))
                {
                    // if classname differs than it is not allowed
                    if (string.Compare(ctx.ClassName, aClassname, true) != 00)
                    {
                        this.NotifyErrorListeners(String.Format(Messages.RCM_12, ctx.ClassName));
                    }
                    else
                    {
                        aClassname = ctx.ClassName;
                    }
                }
            }
            else if (context is SelectExpressionContext)
            {
                SelectExpressionContext ctx = (SelectExpressionContext)context;
                string aDefaultname         = GetDefaultClassName(ctx);
                if (!(String.IsNullOrEmpty(aDefaultname)))
                {
                    aClassname = aDefaultname;
                }
            }
            else if (context is SelectConditionContext)
            {
                SelectConditionContext ctx = (SelectConditionContext)context;
                string aDefaultname        = GetDefaultClassName(ctx);
                if (!(String.IsNullOrEmpty(aDefaultname)))
                {
                    aClassname = aDefaultname;
                }
            }
            else if (context is ResultSelectionContext)
            {
                ResultSelectionContext ctx = (ResultSelectionContext)context;
                string aDefaultname        = GetDefaultClassName(ctx);
                if (string.IsNullOrEmpty(ctx.ClassName))
                {
                    aClassname = GetDefaultClassName(context);
                }
                else if (!String.IsNullOrWhiteSpace(ctx.ClassName))
                {
                    aClassname = ctx.ClassName;
                }
            }

            // check if DataObjectEntry is there
            if (!string.IsNullOrWhiteSpace(aClassname) && Engine.Repository.HasDataObjectDefinition(aClassname))
            {
                return(Engine.Repository.GetDataObjectDefinition(aClassname).HasEntry(anEntryName));
            }
            // no way to get classname and entryname
            return(false);
        }