The content of the invention
The invention provides the definition validity check and device of a kind of object, at least to solve in correlation technique piece
The mode technical sophistication degree for lifting the validity checking of definition is high, the low problem of execution efficiency.
According to an aspect of the invention, there is provided a kind of definition validity check of object, including:Invocation target
The returning an object value character string method of object, and obtain the first return value of returning an object value character string method return;Unsteady state operation institute
Destination object is stated for basic value type;The returning an object value character string method of the destination object after unsteady state operation is called, and
Obtain the second return value that returning an object value character string method is returned;According to first return value and second return value, really
The legitimacy of the definition of the fixed destination object.
Preferably, according to first return value and second return value, the conjunction of the definition of the destination object is determined
Method includes:Judge whether first return value is consistent with second return value;In the case where judged result is consistent,
The legitimacy for determining the definition of the destination object is no.
Preferably, it is determined that the destination object definition legitimacy for after no, methods described also includes:Show institute
State the result that the legitimacy of the definition of destination object is no.
Preferably, in the case where judged result is inconsistent, methods described also includes:Determine determining for the destination object
The legitimacy of justice is yes.
Preferably, the basic value type includes one below:Integer, long.
Preferably, the destination object includes:Be inherited from primary object enumerate or be inherited from primary object enumerate group
Close.
According to another aspect of the present invention, a kind of definition validity checking device of object is additionally provided, including:First
Processing module, for the returning an object value character string method of invocation target object, and obtains the return of returning an object value character string method
First return value;Modular converter, is basic value type for destination object described in unsteady state operation;Second processing module, is used for
The returning an object value character string method of the destination object after unsteady state operation is called, and obtains the return of returning an object value character string method
The second return value;Determining module, for according to first return value and second return value, determining the destination object
Definition legitimacy.
Preferably, the determining module includes:Judging unit, for judging that first return value and described second is returned
Whether value is consistent;First determining unit, in the case of being consistent in judged result, determines the definition of the destination object
Legitimacy is no.
Preferably, described device also includes:Display module, for showing that the legitimacy of definition of the destination object is no
Result.
Preferably, the determining module also includes:Second determining unit, for being inconsistent situation in judged result
Under, the legitimacy for determining the definition of the destination object is yes.
By the present invention, using the returning an object value character string method of invocation target object, and returning an object value character string is obtained
The first return value that method is returned;Unsteady state operation destination object is basic value type;Call the destination object after unsteady state operation
Returning an object value character string method, and obtain returning an object value character string method return the second return value;According to the first return value
With the second return value, the mode of the legitimacy of the definition of destination object is determined, solve the legal of enumeration definition in correlation technique
Property the mode technical sophistication degree that checks it is high, the low problem of execution efficiency reduces the complexity of realization, improves execution efficiency.
Specific embodiment
It should be noted that in the case where not conflicting, the feature in embodiment and embodiment in the application can phase
Mutually combination.Below with reference to the accompanying drawings and in conjunction with the embodiments describing the present invention in detail.
Can be in the such as computer system of one group of computer executable instructions the step of the flow process of accompanying drawing is illustrated
Perform, and, although show logical order in flow charts, but in some cases, can be with suitable different from herein
Sequence performs shown or described step.For example, in the examples below that the step of S104, step S106 the step of and step
The step of S102 can be exchange.
Present embodiments provide a kind of definition validity check of object, Fig. 1 is according to embodiments of the present invention right
The schematic flow sheet of the definition validity check of elephant, as shown in figure 1, the flow process comprises the steps:
Step S102, the returning an object value character string method of invocation target object, and obtain returning an object value character string method and return
The first return value returned;
Step S104, unsteady state operation destination object is basic value type;
Step S106, calls the returning an object value character string method of the destination object after unsteady state operation, and obtains returning an object value
The second return value that character string method is returned;
Step S108, according to the first return value and the second return value, determines the legitimacy of the definition of destination object.
By above-mentioned steps, respectively to the returning an object value character of the destination object after destination object and unsteady state operation type
The mode that the result that string method is returned is compared, to determine the legitimacy of the definition of destination object, relative to correlation technique
For the scheme two of middle offer, due to no longer needing for value to be checked to be converted into binary numeral, each bit is reexamined
On whether have corresponding definition in enumerating, so as to solve correlation technique in enumeration definition validity checking mode technology
Complexity is high, and the low problem of execution efficiency reduces the complexity of realization, improves execution efficiency.
Preferably, step S108 includes:Judge whether the first return value is consistent with the second return value;It is one in judged result
In the case of cause, the legitimacy for determining the definition of destination object is no.
Preferably, it is determined that destination object definition legitimacy for after no, can be with the definition of display target object
The legitimacy result that is no, to notify that the definition of ownership goal object is illegal.
Preferably, also include in step S108:In the case where judged result is inconsistent, determining for destination object is determined
Justice is legal.
Preferably, above-mentioned basic value type includes one below:Integer, long.
Preferably, destination object includes:Be inherited from primary object enumerate or be inherited from primary object enumerate combination.It is logical
The such scheme provided in the present embodiment is provided, is not only able to check the legitimacy of single enumeration object, additionally it is possible to
Hold the legitimacy to enumerating combination to check, fill up the defect existing for scheme one in correlation technique.
The present embodiment additionally provides a kind of definition validity checking device of object, and the device is used to realize above-mentioned object
Definition validity check, the functional realiey in the device embodiment had carried out detailed in said method embodiment
Illustrate, here will not be described in great detail.
Fig. 2 is the structural representation for defining validity checking device of object according to embodiments of the present invention, such as Fig. 2 institutes
Show, the device includes:First processing module 22, modular converter 24, Second processing module 26 and determining module 28, wherein, first
Processing module 22, for the returning an object value character string method of invocation target object, and obtains the return of returning an object value character string method
The first return value;Modular converter 24, is basic value type for unsteady state operation destination object;Second processing module 26 is coupled
To modular converter 24, for calling unsteady state operation after destination object returning an object value character string method, and obtain returning an object value
The second return value that character string method is returned;Determining module 28 is coupled respectively to first processing module 22 and Second processing module
26, for according to the first return value and the second return value, determining the legitimacy of the definition of destination object.
Involved module, unit can be realized by way of software in embodiments of the invention, it is also possible to be passed through
The mode of hardware is realizing.Described module, unit in the present embodiment can also be arranged within a processor, for example, can be with
It is described as:A kind of processor includes first processing module 22, modular converter 24, Second processing module 26 and determining module 28.Its
In, the title of these modules is not constituted under certain conditions to the module restriction of itself, and for example, first processing module may be used also
To be described as " being used for the returning an object value character string method of invocation target object and obtaining the return of returning an object value character string method
The module of the first return value ".
Fig. 3 is the preferred structure schematic diagram one for defining validity checking device of object according to embodiments of the present invention, excellent
Selection of land, determining module 28 includes:Judging unit 282, for judging whether the first return value is consistent with the second return value;First is true
Order unit 284 is coupled to judging unit 282, in the case of being consistent in judged result, determines the definition of destination object
Legitimacy is no.
Fig. 4 is the preferred structure schematic diagram two for defining validity checking device of object according to embodiments of the present invention, excellent
Selection of land, the device also includes:Display module 42 is coupled to the first determining unit 284, for the conjunction of the definition of display target object
The result that method is no.
Fig. 5 is the preferred structure schematic diagram three for defining validity checking device of object according to embodiments of the present invention, excellent
Selection of land, determining module 28 also includes:Second determining unit 286 is coupled to judging unit 282, for being inconsistent in judged result
In the case of, the legitimacy for determining the definition of destination object is yes.
Preferably, above-mentioned basic value type includes one below:Integer, long.
Preferably, destination object includes:Be inherited from primary object enumerate or be inherited from primary object enumerate combination.
It is described with reference to preferred embodiment and illustrates.
This preferred embodiment provides one kind invalid value detection device of enumerated value under .NET, and Fig. 6 is excellent according to the present invention
The workflow schematic diagram of the invalid value detection device of enumerated value under .NET of embodiment is selected, as shown in Figure 6, it is assumed that need detection
Whether some enumeration object M is legal, and the course of work of the device comprises the steps:
Step S1, by existing object M its returning an object value character string is called(ToString())Method, obtains its ToString
Return value afterwards is referred to as A;
Step S2, is transformed into existing object M long types and obtains an object B;
Step S3, will call the return value after B object ToString () methods to be referred to as C;
Step S4, compares whether A and C is identical, if the same proves that M is belonging to the content of non-primary definition(Do not conform to
Method), prove that M is the content of original definition if inconsistent(It is i.e. legal)
Seen from the above description, can be supported to enumerating mark in .NET by the above embodiment of the present invention(Flag)It is special
Property mark detection, and realize and simple efficient define validity checking.In a preferred embodiment of the invention, inspection is put forth effort on
Find and enumerate legal definition(Check that value is the combination of enumerated value definition or enumeration definition), and if illegal can also
Enough dish out run-time exception.It can be seen that, the embodiment of the present invention solve at least the validity checking of enumeration definition in correlation technique
Mode technical sophistication degree is high, and the low problem of execution efficiency reduces the complexity of realization, improves execution efficiency.
Obviously, those skilled in the art should be understood that above-mentioned each module of the invention or each step can be with general
Computing device realizing, they can be concentrated on single computing device, or are distributed in multiple computing devices and are constituted
Network on, alternatively, they can be realized with the executable program code of computing device, it is thus possible to they are stored
Performed by computing device in the storage device, or they be fabricated to respectively each integrated circuit modules, or by they
In multiple modules or step be fabricated to single integrated circuit module to realize.So, the present invention is not restricted to any specific
Hardware and software is combined.
The preferred embodiments of the present invention are more than above are only, the present invention is not limited to, for the skill of this area
For art personnel, the present invention can have various modifications and variations.It is all within the spirit and principles in the present invention, made any repair
Change, equivalent, improvement etc., should be included within the scope of the present invention.