示例#1
0
文件: Render.cs 项目: sundowndk/sCMS
        public override object Process(SorentoLib.Session Session, string Fullname, string Method, object Variable, SorentoLib.Render.Resolver.Parameters Parameters)
        {
            switch (Fullname)
            {
                #region sCMS.Root
                case "scms.root":
                {
                    switch (Method)
                    {
                        case "":
                        {
                            return ((sCMS.Root)Variable);
                        }

                        case "id":
                        {
                            return ((sCMS.Root)Variable).Id;
                        }
                    }
                    break;
                }
                #endregion

                #region sCMS.Page
                case "scms.page":
                {
                    switch (Method)
                    {
                        case "":
                        {
                            return ((sCMS.Page)Variable);
                        }

                        case "id":
                        {
                            return ((sCMS.Page)Variable).Id;
                        }

                        case "createtimestamp":
                        {
                            return ((sCMS.Page)Variable).CreateTimestamp;
                        }

                        case "updatetimestamp":
                        {
                            return ((sCMS.Page)Variable).UpdateTimestamp;
                        }

                        case "title":
                        {
                            return ((sCMS.Page)Variable).Title;
                        }

                        case "path":
                        {
                            return ((sCMS.Page)Variable).Path;
                        }

                        case "template":
                        {
                            return ((sCMS.Page)Variable).Template;
                        }

                        case "root":
                        {
                            return ((sCMS.Page)Variable).Root;
                        }

                        case "childpages":
                        {
                            return ((sCMS.Page)Variable).ChildPages;
                        }

                        case "isparent":
                        {
                            return ((sCMS.Page)Variable).IsParent (Parameters.Get<Guid>(0));
                        }

                        case "getcontent":
                        {
                            switch (Parameters.Type (0).Name.ToLower())
                            {
                                case "guid":
                                {
                                    return ((sCMS.Page)Variable).GetContent (Parameters.Get<Guid>(0));
                                }

                                case "string":
                                {
                                    return ((sCMS.Page)Variable).GetContent (Parameters.Get<string>(0));
                                }
                            }
                            break;
                        }

                        case "load":
                        {
                            switch (Parameters.Type (0).Name.ToLower())
                            {
                                case "guid":
                                    return sCMS.Page.Load (Parameters.Get<Guid>(0));

                                case "string":
                                    return sCMS.Page.Load (new Guid (Parameters.Get<string>(0)));
                            }
                            break;
                        }

                        case "list":
                        {
                            switch (Parameters.Type (0).Name.ToLower())
                            {
                                case "guid":
                                {
                                    return sCMS.Page.List (Parameters.Get<Guid>(0));
                                }

                                default:
                                {
                                    return sCMS.Page.List ();
                                }
                            }

                        }
                    }
                    break;
                }
                #endregion

            // #region sCMS.Template
            // case "scms.template":
            //
            // switch (Method)
            // {
            // case "":
            // return ((sCMS.Template)Variable);
            //
            // case "id":
            // return ((sCMS.Template)Variable).Id;
            //
            // case "createtimestamp":
            // return ((sCMS.Template)Variable).CreateTimestamp;
            //
            // case "updatetimestamp":
            // return ((sCMS.Template)Variable).UpdateTimestamp;
            //
            // case "name":
            // return ((sCMS.Template)Variable).Title;
            //
            // case "fields":
            // return SorentoLib.Render.Variables.ConvertToListObject<sCMS.Field> (((sCMS.Template)Variable).Fields);
            //
            // case "list":
            //// if (Session.AccessLevel < SorentoLib.Enums.Accesslevel.Editor) throw new Exception (string.Format (sCMS.Strings.Exception.ResolverSessionPriviliges, "template.list"));
            //
            // return SorentoLib.Render.Variables.ConvertToListObject<sCMS.Template> (sCMS.Template.List ());
            // }
            // break;
            // #endregion

            #region sCMS.Field
            case "scms.field":
            switch (Method)
            {
            case "":
            return ((sCMS.Field)Variable);

            case "id":
            return ((sCMS.Field)Variable).Id;

            case "name":
            return ((sCMS.Field)Variable).Name;

            case "type":
            return ((sCMS.Field)Variable).Type;
            }
            break;
            #endregion

            #region sCMS.Content
            case "scms.contentdata":

            switch (Method)
            {
            case "":
            return ((sCMS.Content)Variable);

            case "data":
            return ((sCMS.Content)Variable).Data;
            }
            break;
            #endregion

                    #region sCMS.CollectionSchema
                case "scms.collectionschema":
                {
                    switch (Method)
                    {
                        case "":
                        {
                            return ((sCMS.CollectionSchema)Variable);
                        }

            //						case "name":
            //						{
            //							return ((sCMS.CollectionSchema)Variable).Name;
            //						}

                        case "collections":
                        {
                            return ((sCMS.CollectionSchema)Variable).Collections;
                        }

                        case "load":
                        {
                            switch (Parameters.Type (0).Name.ToLower())
                            {
                                case "guid":
                                    return sCMS.CollectionSchema.Load (Parameters.Get<Guid>(0));

                                case "string":
                                    return sCMS.CollectionSchema.Load (new Guid (Parameters.Get<string>(0)));
                            }
                            break;
                        }
                    }
                    break;
                }
            #endregion

            #region sCMS.Collection
                case "scms.collection":
                {

                    switch (Method)
                    {
                        case "":
                        {
                            return ((sCMS.Collection)Variable);
                        }

                        case "id":
                        {
                            return ((sCMS.Collection)Variable).Id;
                        }

                        case "title":
                        {
                            return ((sCMS.Collection)Variable).Title;
                        }

                        case "getcontent":
                        {
                             switch (Parameters.Type (0).Name.ToLower())
                             {
                                case "guid":
                                {
                                    return ((sCMS.Collection)Variable).GetContent (Parameters.Get<Guid>(0));
                                }

                                case "string":
                                {
                                    return ((sCMS.Collection)Variable).GetContent (Parameters.Get<string>(0));
                                }
                             }
                            break;
                        }

                        case "load":
                            switch (Parameters.Type (0).Name.ToLower())
                            {
                                case "guid":
                                    return sCMS.Collection.Load (Parameters.Get<Guid>(0));

                                case "string":
                                    return sCMS.Collection.Load (new Guid (Parameters.Get<string>(0)));
                            }
                            break;
                    }
                    break;
                }
            #endregion
            }

            throw new SorentoLib.Exceptions.RenderExceptionMemberNotFound ();
        }
示例#2
0
        public override object Process(SorentoLib.Session Session, string Fullname, string Method, object Variable, SorentoLib.Render.Resolver.Parameters Parameters)
        {
            switch (Fullname)
            {
                #region SorentoLib.Session
                case "sorentolib.session":
                    switch (Method)
                    {
                        case "":
                            return ((SorentoLib.Session)Variable);

                        case "id":
                            return ((SorentoLib.Session)Variable).Id;

                        case "createtimestamp":
                            return ((SorentoLib.Session)Variable).CreateTimestamp;

                        case "updatetimestamp":
                            return ((SorentoLib.Session)Variable).UpdateTimestamp;

                        case "languages":
                            return SorentoLib.Render.Variables.ConvertToListObject<string> (((SorentoLib.Session)Variable).Languages);

                        case "user":
                            return ((SorentoLib.Session)Variable).User;

                        case "cookiejar":
                            return ((SorentoLib.Session)Variable).Request.CookieJar;

                        case "queryjar":
                            return ((SorentoLib.Session)Variable).Request.QueryJar;

                        case "remoteaddress":
                            return ((SorentoLib.Session)Variable).RemoteAddress;

            //						case "accesslevel":
            //							return ((SorentoLib.Session)Variable).AccessLevel;

                        case "loggedin":
                            return ((SorentoLib.Session)Variable).LoggedIn;

            //						case "authenticatebyaccesslevel":
            //							return ((SorentoLib.Session)Variable).AuthenticateByAccesslevel (SNDK.Convert.StringToEnum<SorentoLib.Enums.Accesslevel>(Parameters.Get<string>(0)));

                        case "authenticate":
                            switch (Parameters.Type (0).Name.ToLower())
                            {
                                case "guid":
                                    return ((SorentoLib.Session)Variable).Authenticate (Parameters.Get<Guid>(0));

                                case "string":
                                    return ((SorentoLib.Session)Variable).Authenticate (Parameters.Get<string>(0));

                                default:
                                    return null;
                            }

                        case "current":
                            return Session;

                        case "error":
                            return Session.Error;
                    }
                    break;
                #endregion

                #region SorentoLib.Error
                case "sorentolib.error":
                    switch (Method)
                    {
                        case "":
                            return ((SorentoLib.Error)Variable);

                        case "id":
                            return ((SorentoLib.Error)Variable).Id;

                        case "title":
                            return ((SorentoLib.Error)Variable).Title;

                        case "text":
                            return ((SorentoLib.Error)Variable).Text;
                    }
                    break;
                #endregion

                #region SorentoLib.FastCgi.CookieJar
                case "sorentolib.fastcgi.cookiejar":
                    switch (Method)
                    {
                        case "":
                            return ((SorentoLib.FastCgi.CookieJar)Variable);

                        case "get":
                            return ((SorentoLib.FastCgi.CookieJar)Variable).Get (Parameters.Get<string> (0));

                        case "exist":
                            return ((SorentoLib.FastCgi.CookieJar)Variable).Exist (Parameters.Get<string> (0));
                    }
                    break;
                #endregion

                #region SorentoLib.FastCgi.Cookie
                case "sorentolib.fastcgi.cookie":
                    switch (Method)
                    {
                        case "":
                            return ((SorentoLib.FastCgi.Cookie)Variable);

                        case "name":
                            return ((SorentoLib.FastCgi.Cookie)Variable).Name;

                        case "domain":
                            return ((SorentoLib.FastCgi.Cookie)Variable).Domain;

                        case "path":
                            return ((SorentoLib.FastCgi.Cookie)Variable).Path;

                        case "expires":
                            return ((SorentoLib.FastCgi.Cookie)Variable).Expires;

                        case "value":
                            return ((SorentoLib.FastCgi.Cookie)Variable).Value;

                        case "secure":
                            return ((SorentoLib.FastCgi.Cookie)Variable).Secure;
                    }
                    break;
                #endregion

                #region SorentoLib.FastCgi.QueryJar
                case "sorentolib.fastcgi.queryjar":
                    switch (Method)
                    {
                        case "":
                            return ((SorentoLib.FastCgi.QueryJar)Variable);

                        case "get":
                            return ((SorentoLib.FastCgi.QueryJar)Variable).Get (Parameters.Get<string>(0));

                        case "exist":
                            return ((SorentoLib.FastCgi.QueryJar)Variable).Exist (Parameters.Get<string>(0));
                    }
                    break;
                #endregion

                #region SorentoLib.FastCgi.Query
                case "sorentolib.fastcgi.query":
                    switch (Method)
                    {
                        case "":
                            return ((SorentoLib.FastCgi.Query)Variable);

                        case "name":
                            return ((SorentoLib.FastCgi.Query)Variable).Name;

                        case "value":
                            return ((SorentoLib.FastCgi.Query)Variable).Value;
                    }
                    break;
                #endregion

                #region SorentoLib.User
                case "sorentolib.user":
                    switch (Method)
                    {
                        case "":
                              return ((SorentoLib.User)Variable);

                        case "id":
                            return ((SorentoLib.User)Variable).Id;

                        case "createtimestamp":
                            return ((SorentoLib.User)Variable).CreateTimestamp;

                        case "updatetimestamp":
                            return ((SorentoLib.User)Variable).UpdateTimestamp;

                        case "username":
                            return ((SorentoLib.User)Variable).Username;

                        case "email":
                            return ((SorentoLib.User)Variable).Email;

                        case "realname":
                            return ((SorentoLib.User)Variable).Realname;

                        case "firstname":
                            return ((SorentoLib.User)Variable).FirstName;

                        case "lastname":
                            return ((SorentoLib.User)Variable).LastName;

            //						case "accesslevel":
            //							return ((SorentoLib.User)Variable).Accesslevel;

                        case "usergroups":
                            return SorentoLib.Render.Variables.ConvertToListObject<SorentoLib.Usergroup> (((SorentoLib.User)Variable).Usergroups);

                        case "status":
                            return ((SorentoLib.User)Variable).Status;

                        case "load":
                            switch (Parameters.Type (0).Name.ToLower())
                            {
                                case "guid":
                                    return SorentoLib.User.Load (Parameters.Get<Guid>(0));

                                case "string":
                                    return SorentoLib.User.Load (Parameters.Get<string>(0));

                                default:
                                    return null;
                            }
                            break;

                        case "list":
                            switch (Parameters.Count)
                            {
                                case 1:
            //									return SorentoLib.Render.Variables.ConvertToListObject<SorentoLib.User> (SorentoLib.User.List(SorentoLib.Enums.UserListFilter.OnlyUsersThatIsMemberOfUsergroupId, Parameters.Get<Guid>(0)));
                                    break;

                                default:
                                    return SorentoLib.Render.Variables.ConvertToListObject<SorentoLib.User> (SorentoLib.User.List());
                            }
                            break;
                      }
                    break;
                #endregion

                #region SorentoLib.Usergroup
                case "sorentolib.usergroup":
                    switch (Method)
                    {
                        case "":
                            return ((SorentoLib.Usergroup)Variable);

                        case "id":
                            return ((SorentoLib.Usergroup)Variable).Id;

                        case "createtimestamp":
                            return ((SorentoLib.Usergroup)Variable).CreateTimestamp;

                        case "updatetimestamp":
                            return ((SorentoLib.Usergroup)Variable).UpdateTimestamp;

                        case "name":
                            return ((SorentoLib.Usergroup)Variable).Name;

            //						case "accesslevel":
            //							return ((SorentoLib.Usergroup)Variable).Accesslevel;

                        case "status":
                            return ((SorentoLib.Usergroup)Variable).Status;

                        case "load":
                            return Usergroup.Load (Parameters.Get<Guid>(0));

                        case "list":
                            switch (Parameters.Count)
                            {
            //								case 2:
            //									return SorentoLib.Render.Variables.ConvertToListObject<SorentoLib.Usergroup> (SorentoLib.Usergroup.List(SorentoLib.Enums.UsergroupListFilter.ExcludeUsergroupsThatUsernameIsMemberOf, (string)Parameters[1]));
            //									return SorentoLib.Render.Variables.ConvertToListObject<SorentoLib.Usergroup> (SorentoLib.Usergroup.List(SorentoLib.Enums.UsergroupListFilter.ExcludeUsergroupsThatUsernameIsMemberOf, (string)Parameters[1]));

                                default:
                                    return SorentoLib.Render.Variables.ConvertToListObject<SorentoLib.Usergroup> (SorentoLib.Usergroup.List());
                            }
                    }
                    break;
                #endregion

                #region SorentoLib.Media
                case "sorentolib.media":
                    switch (Method)
                    {
                        case "":
                            return ((SorentoLib.Media)Variable);

                        case "id":
                            return ((SorentoLib.Media)Variable).Id;

                        case "createtimestamp":
                            return ((SorentoLib.Media)Variable).CreateTimestamp;

                        case "updatetimestamp":
                            return ((SorentoLib.Media)Variable).UpdateTimestamp;

                        case "path":
                            return ((SorentoLib.Media)Variable).Path;

                        case "filename":
            //							return ((SorentoLib.Media)Variable).FileName;

                        case "directoryname":
            //							return ((SorentoLib.Media)Variable).DirectoryName;

                        case "mimetype":
                            return ((SorentoLib.Media)Variable).Mimetype;

                        case "size":
                            return ((SorentoLib.Media)Variable).Size;

                        case "status":
            //							return ((SorentoLib.Media)Variable).Status;

                        case "accesslevel":
            //							return ((SorentoLib.Media)Variable).Accesslevel;

                        case "usergroups":
            //							return SorentoLib.Render.Variables.ConvertToListObject<SorentoLib.Usergroup> (((SorentoLib.Media)Variable).Usergroups);

                        case "load":
                            return SorentoLib.Media.Load (Parameters.Get<Guid>(0));
                    }
                    break;
                #endregion

                #region SorentoLib.Services.Config
                case "sorentolib.services.config":
                    switch (Method)
                    {
                        case "getstring":
                            return SorentoLib.Services.Config.Get<string> (Parameters.Get<string> (0) +"_"+ Parameters.Get<string> (1));
            //
                        case "getbool":
                            return SorentoLib.Services.Config.Get<bool> (Parameters.Get<string> (0) +"_"+ Parameters.Get<string> (1));
            //
                        case "getint":
                            return SorentoLib.Services.Config.Get<int> (Parameters.Get<string> (0) +"_"+ Parameters.Get<string> (1));
            //
                        case "getdecimal":
                            return SorentoLib.Services.Config.Get<decimal> (Parameters.Get<string> (0) +"_"+ Parameters.Get<string> (1));
            //
                        case "getguid":
                            return SorentoLib.Services.Config.Get<Guid> (Parameters.Get<string> (0) +"_"+ Parameters.Get<string> (1));
            //
            //						case "exist":
            //							return SorentoLib.Services.Config.Exist (Parameters.Get<string> (0) +"_"+ Parameters.Get<string> (1));
                    }
                    break;
                #endregion

                #region SorentoLib.Services.Stats
                case "sorentolib.services.stats":
                    switch (Method)
                    {
                        case "getstring":
                            return SorentoLib.Services.Stats.Get<string> (Parameters.Get<string> (0));

                        case "getint":
                            return SorentoLib.Services.Stats.Get<int> (Parameters.Get<string> (0));

                        case "getdecimal":
                            return SorentoLib.Services.Stats.Get<decimal> (Parameters.Get<string> (0));

                        case "exist":
                            return SorentoLib.Services.Stats.Exist (Parameters.Get<string> (0));
                    }
                    break;
                #endregion

                #region SorentoLib.Services.Crypto
                case "sorentolib.services.crypto":
                    switch (Method)
                    {
                        case "encryptexponent":
                            return SorentoLib.Services.Crypto.EncryptExponent;

                        case "modulus":
                            return SorentoLib.Services.Crypto.Modulus;
                    }
                    break;
                #endregion

                #region SorentoLib.Env
                case "sorentolib.env":
                    switch (Method)
                    {
                        case "authtype":
                            return Session.Request.Environment.AuthType;

                        case "contentlength":
                            return Session.Request.Environment.ContentLength;

                        case "contenttype":
                            return Session.Request.Environment.ContentType;

                        case "contenttypemultipartboundary":
                            return Session.Request.Environment.ContentTypeMultipartBoundary;

                        case "documentroot":
                            return Session.Request.Environment.DocumentRoot;

                        case "gatewayinterface":
                            return Session.Request.Environment.GatewayInterface;

                        case "httpaccept":
                            return Session.Request.Environment.HttpAccept;

                        case "httpacceptcharset":
                            return Session.Request.Environment.HttpAcceptCharset;

                        case "httpacceptencoding":
                            return Session.Request.Environment.HttpAcceptEncoding;

                        case "httpacceptlanguage":
                            return Session.Request.Environment.HttpAcceptLanguage;

                        case "httpconnection":
                            return Session.Request.Environment.HttpConnection;

                        case "httpcookie":
                            return Session.Request.Environment.HttpCookie;

                        case "httphost":
                            return Session.Request.Environment.HttpHost;

                        case "httpkeepalive":
                            return Session.Request.Environment.HttpKeepAlive;

                        case "httpreferer":
                            return Session.Request.Environment.HttpReferer;

                        case "httpuseragent":
                            return Session.Request.Environment.HttpUserAgent;

                        case "pathinfo":
                            return Session.Request.Environment.PathInfo;

                        case "pathtranslated":
                            return Session.Request.Environment.PathTranslated;

                        case "querystring":
                            return Session.Request.Environment.QueryString;

                        case "redirectquerystring":
                            return Session.Request.Environment.RedirectQueryString;

                        case "redirectstatus":
                            return Session.Request.Environment.RedirectStatus;

                        case "redirecturl":
                            return Session.Request.Environment.RedirectUrl;

                        case "remoteaddress":
                            return Session.Request.Environment.RemoteAddress;

                        case "remotehost":
                            return Session.Request.Environment.RemoteHost;

                        case "remoteident":
                            return Session.Request.Environment.RemoteIdent;

                        case "remoteuser":
                            return Session.Request.Environment.RemoteUser;

                        case "requestmethod":
                            return Session.Request.Environment.RequestMethod;

                        case "requesturi":
                            return Session.Request.Environment.RequestUri;

                        case "serveraddress":
                            return Session.Request.Environment.ServerAddress;

                        case "serveradmin":
                            return Session.Request.Environment.ServerAdmin;

                        case "servername":
                            return Session.Request.Environment.ServerName;

                        case "serverport":
                            return Session.Request.Environment.ServerPort;

                        case "serverprotocol":
                            return Session.Request.Environment.ServerProtocol;

                        case "serversignature":
                            return Session.Request.Environment.ServerSignature;

                        case "serversoftware":
                            return Session.Request.Environment.ServerSoftware;

                        case "version":
                            return SorentoLib.Runtime.GetVersionString ();

                        case "compiledate":
                            return SorentoLib.Runtime.GetCompileDate ();
                    }
                    break;
                #endregion

                #region System.Guid
                case "system.guid":
                    switch (Method)
                    {
                        case "":
                            return ((Guid)Variable);

                        case "tostring":
                            return ((Guid)Variable).ToString();

                        case "new":
                            switch (Parameters.Count)
                            {
                                case 1:
                                    return new Guid (Parameters.Get<string> (0));

                                default:
                                    return Guid.NewGuid();
                            }
                    }
                    break;
                #endregion

                #region System.String
                case "system.string":
                    switch (Method)
                    {
                        case "":
                            return ((string)Variable);

                        case "length":
                            return ((string)Variable);

                        case "padleft":
                            return ((string)Variable).PadLeft (Parameters.Get<int> (0), Parameters.Get<string> (1)[0]);

                        case "padright":
                            return ((string)Variable).PadRight (Parameters.Get<int> (0), Parameters.Get<string> (1)[0]);

                        case "substring":
                            return ((string)Variable).Substring (Parameters.Get<int> (0), Parameters.Get<int> (1));

                        case "removenewline":
                            return ((string)Variable).Replace (System.Environment.NewLine, string.Empty);

                        case "replace":
                            //SorentoLib.Services.Logging.LogDebug ("Char:"+Parameters.Get<string> (0));
                            return ((string)Variable).Replace (Parameters.Get<string> (0), Parameters.Get<string> (1));
                            //string test = "\n";
                            //return ((string)Variable).Replace (test, Parameters.Get<string> (1));
                            //return ((string)Variable).Replace (System.Environment.NewLine, Parameters.Get<string> (1));

                        case "split":
                            return ((string)Variable).Split (Parameters.Get<string> (0).ToCharArray (), StringSplitOptions.RemoveEmptyEntries);

                        case "tolower":
                            return ((string)Variable).ToLower ();

                        case "toupper":
                            return ((string)Variable).ToUpper ();

                        case "nolinebreak":
                            return ((string)Variable).Replace ("\n","").Replace ("\r","");

                        case "truncate":
                            switch (Parameters.Count)
                            {
                                case 2:
                                    if (Parameters.Get<int> (0) < ((string)Variable).Length)
                                    {
                                        return ((string)Variable).Substring (0, Parameters.Get<int> (0)) + Parameters.Get<string> (1);
                                    }
                                    else
                                    {
                                        return (string)Variable;
                                    }

                                default:
                                    if (Parameters.Get<int> (0) < ((string)Variable).Length)
                                    {
                                        return ((string)Variable).Substring (0, Parameters.Get<int> (0));
                                    }
                                    else
                                    {
                                        return (string)Variable;
                                    }
                            }
                    }
                    break;
                #endregion

                #region System.String[]
                case "system.string[]":
                    switch (Method)
                    {
                        case "":
                            if (Parameters.Count > 0)
                            {
                                return ((string[])Variable)[Parameters.Get<int> (0)];
                            }
                            else
                            {
                                return ((string[])Variable);
                            }

                        case "length":
                            return ((string[])Variable).Length;
                    }
                    break;
                #endregion

                #region System.Int
                case "system.int32":
                    switch (Method)
                    {
                        case "":
                            return ((int)Variable);

                        case "tostring":
                            return ((int)Variable).ToString ();
                    }
                    break;
                #endregion

                #region System.Boolean
                case "system.boolean":
                    switch (Method)
                    {
                        case "":
                        {
                            return ((bool)Variable);
                        }
                    }
                    break;
                #endregion

                #region System.Datetime
                case "system.datetime":
                    switch (Method)
                    {
                        case "":
                            return ((DateTime)Variable);

                        case "day":
                            return ((DateTime)Variable).Day;

                        case "month":
                            return ((DateTime)Variable).Month;

                        case "year":
                            return ((DateTime)Variable).Year;

                        case "hour":
                            return ((DateTime)Variable).Hour;

                        case "minute":
                            return ((DateTime)Variable).Minute;

                        case "second":
                            return ((DateTime)Variable).Second;

                        case "millisecond":
                            return ((DateTime)Variable).Millisecond;

                        case "dayofweek":
                            return ((DateTime)Variable).DayOfWeek;

                        case "dayofyear":
                            return ((DateTime)Variable).DayOfYear;

                        case "now":
                            return DateTime.Now;

                        case "fromtimestamp":
                            return SNDK.Date.TimestampToDateTime (Parameters.Get<int> (0));
                    }
                    break;
                #endregion

                #region System.Collections.Generic
                case "system.collections.generic.list`1":
                    switch (Method)
                    {
                        case "":
                            return (object)Variable;

                        case "count":
                            MethodInfo methodInfo = typeof(SorentoLib.Render.Variables).GetMethod("ConvertToListObjectNew", System.Reflection.BindingFlags.Static | BindingFlags.Public);
                        MethodInfo genericMethodInfo = methodInfo.MakeGenericMethod(new Type[] { ((object)Variable).GetType ().GetGenericArguments()[0] });
                        List<object> returnvalue = (List<object>)genericMethodInfo.Invoke(null, new object[] { (object)Variable });

                            return returnvalue.Count;
                    }
                    break;
                #endregion

                #region System.Collections.Hashtable
                case "system.collections.hashtable":
            //					Console.WriteLine ("11");
                    switch (Method)
                    {
                        case "":
                            return ((Hashtable)Variable);

                        case "get":
                            return ((Hashtable)Variable)[Parameters.Get<string> (0)];

                        case "keys":
                            List<string> result = new List<string> ();
                            foreach (string key in ((Hashtable)Variable).Keys)
                            {
                                result.Add (key);
                            }
                            return SorentoLib.Render.Variables.ConvertToListObject<string> (result);
                    }
                    break;
                #endregion

                #region System.Version
                case "system.version":
                {
                    switch (Method)
                    {
                        case "":
                            return ((Version)Variable);

                        case "major":
                            return ((Version)Variable).Major;

                        case "minor":
                            return ((Version)Variable).Minor;

                        case "Build":
                            return ((Version)Variable).Build;

                        case "Revision":
                            return ((Version)Variable).Revision;

                        case "MajorRevision":
                            return ((Version)Variable).MajorRevision;

                        case "MinorRevision":
                            return ((Version)Variable).MinorRevision;
                    }
                    break;
                }
                #endregion
            }

            throw new SorentoLib.Exceptions.RenderExceptionMemberNotFound ();
        }
示例#3
0
        public override object Process(SorentoLib.Session Session, string Fullname, string Method, object Variable, SorentoLib.Render.Resolver.Parameters Parameters)
        {
            switch (Fullname)
            {
                #region Didius.Customer
                case "didius.customer":
                {
                    switch (Method)
                    {
                        case "":
                        {
                            return ((Didius.Customer)Variable);
                        }

                        case "id":
                        {
                            return ((Didius.Customer)Variable).Id;
                        }

                        case "load":
                        {
                            switch (Parameters.Type (0).Name.ToLower())
                            {
                                case "user":
                                {
                                    return Didius.Customer.Load (Parameters.Get<SorentoLib.User>(0));
                                }

                                case "guid":
                                    return Didius.Customer.Load (Parameters.Get<Guid>(0));

                                case "string":
                                    return Didius.Customer.Load (new Guid (Parameters.Get<string>(0)));
                            }
                            break;
                        }
                    }
                    break;
                }
                #endregion

                    #region Didius.Helpers
                case "didius.helpers":
                {
                    switch (Method)
                    {
                        case "getauctionscustomerbidon":
                        {
                            return Didius.Helpers.GetAuctionsCustomerBidOn (Parameters.Get<Customer>(0));
                        }

                        case "getitemscustomerbidon":
                        {
                            return Didius.Helpers.GetItemsCustomerBidOn (Parameters.Get<Customer>(0), Parameters.Get<Auction>(1));
                        }

                        case "getcustomershighbidonitem":
                        {
                            return Didius.Helpers.GetCustomersHighBidOnItem (Parameters.Get<Customer>(0), Parameters.Get<Item>(1));
                        }
                    }
                    break;
                }
                #endregion

                #region Didius.Auction
                case "didius.auction":
                {
                    switch (Method)
                    {
                        case "":
                        {
                            return ((Didius.Auction)Variable);
                        }

                        case "id":
                        {
                            return ((Didius.Auction)Variable).Id;
                        }

                        case "no":
                        {
                            return ((Didius.Auction)Variable).No;
                        }

                        case "begin":
                        {
                            return ((Didius.Auction)Variable).Begin;
                        }

                        case "end":
                        {
                            return ((Didius.Auction)Variable).End;
                        }

                        case "location":
                        {
                            return ((Didius.Auction)Variable).Location;
                        }

                        case "deadline":
                        {
                            return ((Didius.Auction)Variable).Deadline;
                        }

                        case "title":
                        {
                            return ((Didius.Auction)Variable).Title;
                        }

                        case "description":
                        {
                            return ((Didius.Auction)Variable).Description;
                        }

                        case "type":
                        {
                            return ((Didius.Auction)Variable).Type;
                        }

                        case "status":
                        {
                            return ((Didius.Auction)Variable).Status;
                        }

                        case "load":
                        {
                            switch (Parameters.Type (0).Name.ToLower())
                            {
                                case "guid":
                                    return Didius.Auction.Load (Parameters.Get<Guid>(0));

                                case "string":
                                    return Didius.Auction.Load (new Guid (Parameters.Get<string>(0)));
                            }
                            break;
                        }

                        case "list":
                        {
                            return Didius.Auction.List ();
                        }
                    }
                    break;
                }
                #endregion

                #region Didius.Case
                case "didius.case":
                {
                    switch (Method)
                    {
                        case "":
                        {
                            return ((Didius.Case)Variable);
                        }

                        case "id":
                        {
                            return ((Didius.Case)Variable).Id;
                        }

                        case "auctionid":
                        {
                            return ((Didius.Case)Variable).AuctionId;
                        }

                        case "load":
                        {
                            switch (Parameters.Type (0).Name.ToLower())
                            {
                                case "guid":
                                    return Didius.Case.Load (Parameters.Get<Guid>(0));

                                case "string":
                                    return Didius.Case.Load (new Guid (Parameters.Get<string>(0)));
                            }
                            break;
                        }
                    }
                    break;
                }
                #endregion

                #region Didius.Item
                case "didius.item":
                {
                    switch (Method)
                    {
                        case "":
                        {
                            return ((Didius.Item)Variable);
                        }

                        case "id":
                        {
                            return ((Didius.Item)Variable).Id;
                        }

                        case "caseid":
                        {
                            return ((Didius.Item)Variable).CaseId;
                        }

                        case "auctionid":
                        {
                            return ((Didius.Item)Variable).Case.Auction.Id;
                        }

                        case "no":
                        {
                            return ((Didius.Item)Variable).No;
                        }

                        case "catalogno":
                        {
                            return ((Didius.Item)Variable).CatalogNo;
                        }

                        case "vat":
                        {
                            return ((Didius.Item)Variable).Vat;
                        }

                        case "title":
                        {
                            return ((Didius.Item)Variable).Title;
                        }

                        case "description":
                        {
                            return ((Didius.Item)Variable).Description;
                        }

                        case "pictureid":
                        {
                            return ((Didius.Item)Variable).PictureId;
                        }

                        case "currentbid":
                        {
                            return ((Didius.Item)Variable).CurrentBid;
                        }

                        case "bidamount":
                        {
                            return ((Didius.Item)Variable).BidAmount;
                        }

                        case "nextbidamount":
                        {
                            return ((Didius.Item)Variable).NextBidAmount;
                        }

                        case "onlinebid":
                        {
                            Didius.Item.OnlineBid (Parameters.Get<Didius.Customer>(0), Parameters.Get<Didius.Item>(1));
                            break;
                        }

                        case "load":
                        {
                            switch (Parameters.Type (0).Name.ToLower())
                            {
                                case "guid":
                                    return Didius.Item.Load (Parameters.Get<Guid>(0));

                                case "string":
                                    return Didius.Item.Load (new Guid (Parameters.Get<string>(0)));
                            }
                            break;
                        }

                        case "list":
                        {
                            if (Parameters.Count == 1)
                            {
                                switch (Parameters.Type (0).Name.ToLower())
                                {
                                    case "auction":
                                    {
                                        return Didius.Item.List (Parameters.Get<Didius.Auction>(0));
                                    }

                                    default:
                                    {
                                        return Didius.Item.List ();
                                    }
                                }
                            }
                            else if (Parameters.Count == 3)
                            {
                                switch (Parameters.Type (0).Name.ToLower())
                                {
                                    case "auction":
                                    {
                                        return Didius.Item.List (Parameters.Get<Didius.Auction>(0)).GetRange (Parameters.Get<int> (1), Parameters.Get<int> (2));
                                    }

                                    default:
                                    {
                                        return Didius.Item.List ().GetRange (Parameters.Get<int> (1), Parameters.Get<int> (2));
                                    }
                                }
                            }
                            break;
                        }
                    }
                    break;
                }
                #endregion

                #region Didius.Bid
                case "didius.bid":
                {
                    switch (Method)
                    {
                        case "":
                        {
                            return ((Didius.Bid)Variable);
                        }

                        case "id":
                        {
                            return ((Didius.Bid)Variable).Id;
                        }

                        case "createtimestamp":
                        {
                            return ((Didius.Bid)Variable).CreateTimestamp;
                        }

                        case "updatetimestamp":
                        {
                            return ((Didius.Bid)Variable).UpdateTimestamp;
                        }

                        case "itemid":
                        {
                            return ((Didius.Bid)Variable).ItemId;
                        }

                        case "customerid":
                        {
                            return ((Didius.Bid)Variable).CustomerId;
                        }

                        case "amount":
                        {
                            return ((Didius.Bid)Variable).Amount;
                        }

                        case "load":
                        {
                            switch (Parameters.Type (0).Name.ToLower())
                            {
                                case "guid":
                                    return Didius.Bid.Load (Parameters.Get<Guid>(0));

                                case "string":
                                    return Didius.Bid.Load (new Guid (Parameters.Get<string>(0)));
                            }
                            break;
                        }

                        case "list":
                        {
                            switch (Parameters.Type (0).Name.ToLower())
                            {
                                case "customer":
                                {
                                    return Didius.Bid.List (Parameters.Get<Didius.Customer>(0));
                                }

                                case "item":
                                {
                                    return Didius.Bid.List (Parameters.Get<Didius.Item>(0));
                                }

                                default:
                                {
                                    return Didius.Bid.List ();
                                }
                            }
                        }
                    }
                    break;
                }
                #endregion

                #region Didius.AutoBid
                case "didius.autobid":
                {
                    switch (Method)
                    {
                        case "":
                        {
                            return ((Didius.AutoBid)Variable);
                        }

                        case "id":
                        {
                            return ((Didius.AutoBid)Variable).Id;
                        }

                        case "createtimestamp":
                        {
                            return ((Didius.AutoBid)Variable).CreateTimestamp;
                        }

                        case "updatetimestamp":
                        {
                            return ((Didius.AutoBid)Variable).UpdateTimestamp;
                        }

                        case "itemid":
                        {
                            return ((Didius.AutoBid)Variable).ItemId;
                        }

                        case "customerid":
                        {
                            return ((Didius.AutoBid)Variable).CustomerId;
                        }

                        case "amount":
                        {
                            return ((Didius.AutoBid)Variable).Amount;
                        }

                        case "load":
                        {
                            switch (Parameters.Type (0).Name.ToLower())
                            {
                                case "guid":
                                    return Didius.AutoBid.Load (Parameters.Get<Guid>(0));

                                case "string":
                                    return Didius.AutoBid.Load (new Guid (Parameters.Get<string>(0)));
                            }
                            break;
                        }

                        case "list":
                        {
                            switch (Parameters.Type (0).Name.ToLower())
                            {
                                case "customer":
                                {
                                    return Didius.AutoBid.List (Parameters.Get<Didius.Customer>(0));
                                }

                                case "item":
                                {
                                    return Didius.AutoBid.List (Parameters.Get<Didius.Item>(0));
                                }

                                default:
                                {
                                    return Didius.AutoBid.List ();
                                }
                            }
                        }
                    }
                    break;
                }
                #endregion
            }

            throw new SorentoLib.Exceptions.RenderExceptionMemberNotFound ();
        }